Skip to content

Commit

Permalink
docs: Exclude test files from dockgen, make go.doc
Browse files Browse the repository at this point in the history
  • Loading branch information
HomayoonAlimohammadi committed Feb 20, 2025
1 parent 4c16796 commit b375077
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions docs/canonicalk8s/_parts/bootstrap_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ Configuration options for the network feature.
Determines if the feature should be enabled.
If omitted defaults to `true`

### cluster-config.network.pod-cidr
**Type:** `string`<br>

PodCIDR is the CIDR range for the pods in the cluster.

### cluster-config.network.service-cidr
**Type:** `string`<br>

ServiceCIDR is the CIDR range for the services in the cluster.

### cluster-config.dns
**Type:** `object`<br>

Expand Down
8 changes: 7 additions & 1 deletion src/k8s/pkg/docgen/godoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (
"go/doc"
"go/parser"
"go/token"
"io/fs"
"reflect"
"strings"
)

var packageDocCache = make(map[string]*doc.Package)
Expand Down Expand Up @@ -48,7 +50,11 @@ func getStructTypeFromDoc(packageDoc *doc.Package, structName string) (*ast.Stru

func parsePackageDir(packageDir string) (*ast.Package, error) {
fset := token.NewFileSet()
packages, err := parser.ParseDir(fset, packageDir, nil, parser.ParseComments)
// NOTE(Hue): We only want to parse non-test files.
nonTestPackagesFilter := func(info fs.FileInfo) bool {
return !strings.HasSuffix(info.Name(), "_test.go")
}
packages, err := parser.ParseDir(fset, packageDir, nonTestPackagesFilter, parser.ParseComments)
if err != nil {
return nil, fmt.Errorf("couldn't parse go package: %s", packageDir)
}
Expand Down

0 comments on commit b375077

Please sign in to comment.