From a3bcb80fe3bf5b179000acc06511b95822ca8498 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Tue, 10 Jan 2023 14:43:18 +0100 Subject: [PATCH] improve template and sort results Signed-off-by: jkoberg --- docs/helpers/adoc-generator.go.tmpl | 12 +++++++++++- docs/templates/ADOC_global.tmpl | 11 +++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/docs/helpers/adoc-generator.go.tmpl b/docs/helpers/adoc-generator.go.tmpl index a66300f1fa..977363ad15 100644 --- a/docs/helpers/adoc-generator.go.tmpl +++ b/docs/helpers/adoc-generator.go.tmpl @@ -9,10 +9,12 @@ import ( "regexp" "strings" "text/template" + "sort" {{- range $key, $value := .}} pkg{{$key}} "{{$value}}" - {{- end}}) + {{- end}} +) // ConfigField is the representation of one configuration field type ConfigField struct { @@ -83,6 +85,9 @@ func main() { for _, e := range f.EnvVars { if env, ok := all[e]; ok { env.Services = append(env.Services, service) + sort.Slice(env.Services, func(i, j int) bool { + return env.Services[i] < env.Services[j] + }) all[e] = env } else { all[e] = EnvVar{ @@ -130,6 +135,11 @@ func main() { } } + // sort + sort.Slice(tmplValues, func(i, j int) bool { + return tmplValues[i]["Name"].(string) < tmplValues[j]["Name"].(string) + }) + glc, err := os.ReadFile("../../docs/templates/ADOC_global.tmpl") if err != nil { log.Fatal(err) diff --git a/docs/templates/ADOC_global.tmpl b/docs/templates/ADOC_global.tmpl index aaaae12e0f..cbc43b850c 100644 --- a/docs/templates/ADOC_global.tmpl +++ b/docs/templates/ADOC_global.tmpl @@ -1,6 +1,9 @@ +// collected through docs/helpers/adoc-generator.go.tmpl + +[.landscape] [caption=] .Environment variables with global scope available in multiple services -[width="100%",cols="~,~,~,~,~",options="header"] +[width="100%",cols="30%,25%,~,~,~",options="header"] |=== | Name | Services @@ -12,9 +15,9 @@ a| `{{ .Name }}` -a| [subs=-attributes] +a| [subs=attributes+] {{- range .Services}} -xref:{s-path}/{{ . }}.adoc[{{ . }}] + +* xref:{s-path}/{{ . }}.adoc[{{ . }}] + {{- end }} a| [subs=-attributes] @@ -24,7 +27,7 @@ a| [subs=-attributes] ++{{ .DefaultValue }} ++ a| [subs=-attributes] -++{{ .Description }} ++ +{{ .Description }} {{- end }} |===