improve template and sort results

Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
jkoberg committed 2023-01-10 16:48:32 +01:00
1 parent bb9c65db7b
commit a3bcb80fe3
2 files changed
+18 -5

No files matched your search

+11 -1
View File
@@ -9,10 +9,12 @@ import (
"regexp" "regexp"
"strings" "strings"
"text/template" "text/template"
"sort"
{{- range $key, $value := .}} {{- range $key, $value := .}}
pkg{{$key}} "{{$value}}" pkg{{$key}} "{{$value}}"
{{- end}}) {{- end}}
)
// ConfigField is the representation of one configuration field // ConfigField is the representation of one configuration field
type ConfigField struct { type ConfigField struct {
@@ -83,6 +85,9 @@ func main() {
for _, e := range f.EnvVars { for _, e := range f.EnvVars {
if env, ok := all[e]; ok { if env, ok := all[e]; ok {
env.Services = append(env.Services, service) 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 all[e] = env
} else { } else {
all[e] = EnvVar{ 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") glc, err := os.ReadFile("../../docs/templates/ADOC_global.tmpl")
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
+7 -4
View File
@@ -1,6 +1,9 @@
// collected through docs/helpers/adoc-generator.go.tmpl
[.landscape]
[caption=] [caption=]
.Environment variables with global scope available in multiple services .Environment variables with global scope available in multiple services
[width="100%",cols="~,~,~,~,~",options="header"] [width="100%",cols="30%,25%,~,~,~",options="header"]
|=== |===
| Name | Name
| Services | Services
@@ -12,9 +15,9 @@
a| `{{ .Name }}` a| `{{ .Name }}`
a| [subs=-attributes] a| [subs=attributes+]
{{- range .Services}} {{- range .Services}}
xref:{s-path}/{{ . }}.adoc[{{ . }}] + * xref:{s-path}/{{ . }}.adoc[{{ . }}] +
{{- end }} {{- end }}
a| [subs=-attributes] a| [subs=-attributes]
@@ -24,7 +27,7 @@ a| [subs=-attributes]
++{{ .DefaultValue }} ++ ++{{ .DefaultValue }} ++
a| [subs=-attributes] a| [subs=-attributes]
++{{ .Description }} ++ {{ .Description }}
{{- end }} {{- end }}
|=== |===