From 70d6564d7da6d1a896427ae4e8d8cac3110912a0 Mon Sep 17 00:00:00 2001 From: "Lukacs T. Berki" Date: Wed, 8 Sep 2021 09:27:13 +0200 Subject: [PATCH] Prefix file names with ctx.SrcDir() in docgen. This is because docgen will be called from the bootstrap Ninja file with cwd == /. Side cleanup: remove an unused template. Test: Presubmits. Change-Id: Ia5ff10247becbabc7a76c21f4ed05d654a7b20c3 --- bootstrap/writedocs.go | 81 ++---------------------------------------- 1 file changed, 3 insertions(+), 78 deletions(-) diff --git a/bootstrap/writedocs.go b/bootstrap/writedocs.go index 3283e20..f7314f7 100644 --- a/bootstrap/writedocs.go +++ b/bootstrap/writedocs.go @@ -2,6 +2,7 @@ package bootstrap import ( "fmt" + "path/filepath" "reflect" "github.com/google/blueprint" @@ -11,7 +12,7 @@ import ( // ModuleTypeDocs returns a list of bpdoc.ModuleType objects that contain information relevant // to generating documentation for module types supported by the primary builder. -func ModuleTypeDocs(ctx *blueprint.Context, config interface{}, factories map[string]reflect.Value) ([]*bpdoc.Package, error) { +func ModuleTypeDocs(ctx *blueprint.Context, factories map[string]reflect.Value) ([]*bpdoc.Package, error) { // Find the module that's marked as the "primary builder", which means it's // creating the binary that we'll use to generate the non-bootstrap // build.ninja file. @@ -41,7 +42,7 @@ func ModuleTypeDocs(ctx *blueprint.Context, config interface{}, factories map[st switch m := module.(type) { case (*goPackage): pkgFiles[m.properties.PkgPath] = pathtools.PrefixPaths(m.properties.Srcs, - ctx.ModuleDir(m)) + filepath.Join(ctx.SrcDir(), ctx.ModuleDir(m))) default: panic(fmt.Errorf("unknown dependency type %T", module)) } @@ -60,79 +61,3 @@ func ModuleTypeDocs(ctx *blueprint.Context, config interface{}, factories map[st return bpdoc.AllPackages(pkgFiles, mergedFactories, ctx.ModuleTypePropertyStructs()) } - -const ( - fileTemplate = ` - - -Build Docs - - - - - -

Build Docs

-
- {{range .}} -

{{.Text}}

- {{range .ModuleTypes}} - {{ $collapseIndex := unique }} -
- -
-
-
-

{{.Text}}

- {{range .PropertyStructs}} -

{{.Text}}

- {{template "properties" .Properties}} - {{end}} -
-
- {{end}} - {{end}} -
- - - -{{define "properties"}} -
- {{range .}} - {{$collapseIndex := unique}} - {{if .Properties}} - -
-
-

{{.Text}}

- {{range .OtherTexts}}

{{.}}

{{end}} - {{template "properties" .Properties}} -
-
- {{else}} -
-

{{.Name}}{{range .OtherNames}}, {{.}}{{end}}

-

{{.Text}}

- {{range .OtherTexts}}

{{.}}

{{end}} -

Type: {{.Type}}

- {{if .Default}}

Default: {{.Default}}

{{end}} -
- {{end}} - {{end}} -
-{{end}} -` -)