From 454078b83c9acbd9d55ab43e50fa9c35f0d407b0 Mon Sep 17 00:00:00 2001 From: Juan Date: Thu, 17 Dec 2020 10:04:16 +0100 Subject: [PATCH] Version template for package docs --- apmpackage/README.md | 2 +- apmpackage/{ => apm/0.1.0/_dev}/docs/README.template.md | 0 apmpackage/cmd/gen-package/gendocs.go | 4 ++-- apmpackage/cmd/gen-package/paths.go | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) rename apmpackage/{ => apm/0.1.0/_dev}/docs/README.template.md (100%) diff --git a/apmpackage/README.md b/apmpackage/README.md index 1d0e25b1541..f54dcf147c6 100644 --- a/apmpackage/README.md +++ b/apmpackage/README.md @@ -10,7 +10,7 @@ #### Update / fix a package 1. Actual work - - Make changes in `apmpackage/apm/`, `apmpackage/docs/README.template.md` and/or code as needed + - Make changes in `apmpackage/apm/` and/or code as needed - Run `make update`. That will update fields, pipeline and doc files based on apm-server fields and pipeline defs. 2. Run the registry diff --git a/apmpackage/docs/README.template.md b/apmpackage/apm/0.1.0/_dev/docs/README.template.md similarity index 100% rename from apmpackage/docs/README.template.md rename to apmpackage/apm/0.1.0/_dev/docs/README.template.md diff --git a/apmpackage/cmd/gen-package/gendocs.go b/apmpackage/cmd/gen-package/gendocs.go index 9ca93c63c2f..42d85601021 100644 --- a/apmpackage/cmd/gen-package/gendocs.go +++ b/apmpackage/cmd/gen-package/gendocs.go @@ -36,10 +36,10 @@ func generateDocs(inputFields map[string][]field, version string) { MetricsExample: loadExample("metricsets.json"), ErrorExample: loadExample("errors.json"), } - t := template.New(docsTemplateFilePath) + t := template.New(docsTemplateFilePath(version)) tmpl, err := t.Funcs(map[string]interface{}{ "Trim": strings.TrimSpace, - }).ParseFiles(docsTemplateFilePath) + }).ParseFiles(docsTemplateFilePath(version)) if err != nil { panic(err) } diff --git a/apmpackage/cmd/gen-package/paths.go b/apmpackage/cmd/gen-package/paths.go index d15b858e257..0a966a9f96b 100644 --- a/apmpackage/cmd/gen-package/paths.go +++ b/apmpackage/cmd/gen-package/paths.go @@ -19,7 +19,9 @@ package main import "path/filepath" -var docsTemplateFilePath = "apmpackage/docs/README.template.md" +func docsTemplateFilePath(version string) string { + return filepath.Join("apmpackage/apm/", version, "/_dev/docs/README.template.md") +} func docsFilePath(version string) string { return filepath.Join("apmpackage/apm/", version, "/docs/README.md")