Skip to content

Commit

Permalink
improve template and sort results
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <[email protected]>
  • Loading branch information
kobergj committed Jan 10, 2023
1 parent bb9c65d commit a3bcb80
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
12 changes: 11 additions & 1 deletion docs/helpers/adoc-generator.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 7 additions & 4 deletions docs/templates/ADOC_global.tmpl
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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]
Expand All @@ -24,7 +27,7 @@ a| [subs=-attributes]
++{{ .DefaultValue }} ++

a| [subs=-attributes]
++{{ .Description }} ++
{{ .Description }}

{{- end }}
|===

0 comments on commit a3bcb80

Please sign in to comment.