Skip to content

Commit

Permalink
docs: cap max heading level
Browse files Browse the repository at this point in the history
Markdown/HTML can't have headings after level 6, so make sure the
maximum heading level is capped at 6.

We have just a single place with such deep nesting.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
  • Loading branch information
smira committed Dec 11, 2023
1 parent 6bb1e99 commit 04e7745
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions pkg/machinery/config/encoder/markdown.go
Expand Up @@ -43,6 +43,7 @@ func (fd *FileDoc) Encode(root *Doc, frontmatter func(title, description string)
"trimPrefix": strings.TrimPrefix,
"add": func(a, b int) int { return a + b },
"frontmatter": frontmatter,
"min": minInt,
}).
Parse(markdownTemplate))

Expand Down Expand Up @@ -189,3 +190,7 @@ func tmplDict(vals ...any) (map[string]any, error) {

return res, nil
}

func minInt(a, b int) int {
return min(a, b)
}
2 changes: 1 addition & 1 deletion pkg/machinery/config/encoder/markdown.tmpl
@@ -1,7 +1,7 @@
{{ frontmatter .Root.Type .Root.Description }}

{{ block "struct" dict "Struct" .Root "Level" 1 "Name" .Root.Type "Path" .Root.Type "Types" .Types }}
{{ if gt .Level 1 }}{{ repeat "#" .Level }} {{ .Name }} {#{{ .Path }}}{{ end }}
{{ if gt .Level 1 }}{{ repeat "#" (min .Level 6) }} {{ .Name }} {#{{ .Path }}}{{ end }}

{{ if and .Struct.Description (gt .Level 1) -}}
{{ .Struct.Description }}
Expand Down
Expand Up @@ -1454,7 +1454,7 @@ machine:



####### equinixMetal {#Config.machine.network.interfaces..vlans..vip.equinixMetal}
###### equinixMetal {#Config.machine.network.interfaces..vlans..vip.equinixMetal}

VIPEquinixMetalConfig contains settings for Equinix Metal VIP management.

Expand All @@ -1470,7 +1470,7 @@ VIPEquinixMetalConfig contains settings for Equinix Metal VIP management.



####### hcloud {#Config.machine.network.interfaces..vlans..vip.hcloud}
###### hcloud {#Config.machine.network.interfaces..vlans..vip.hcloud}

VIPHCloudConfig contains settings for Hetzner Cloud VIP management.

Expand Down

0 comments on commit 04e7745

Please sign in to comment.