Merge pull request #19539 from dvdksn/cli-reference-tpl-fixups

cli reference template improvements
This commit is contained in:
David Karlsson 2024-03-01 17:02:10 +01:00 committed by GitHub
commit 6a1bb3da95
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 82 additions and 57 deletions

View File

@ -94,6 +94,8 @@
{{ . | $.RenderString (dict "display" "block") }} {{ . | $.RenderString (dict "display" "block") }}
{{ end }} {{ end }}
{{ with $data.options }} {{ with $data.options }}
{{ $opts := where . "hidden" false }}
{{ with $opts }}
{{ $heading := dict "level" 2 "text" "Options" }} {{ $heading := dict "level" 2 "text" "Options" }}
{{ partial "heading.html" $heading }} {{ partial "heading.html" $heading }}
{{ $.Scratch.Add "headings" $heading }} {{ $.Scratch.Add "headings" $heading }}
@ -106,7 +108,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{ range where . "hidden" false }} {{ range . }}
<tr> <tr>
{{ $short := .shorthand }} {{ $short := .shorthand }}
{{ $long := .option }} {{ $long := .option }}
@ -154,6 +156,7 @@
</tbody> </tbody>
</table> </table>
{{ end }} {{ end }}
{{ end }}
{{ with $data.examples }} {{ with $data.examples }}
{{ $heading := dict "level" 2 "text" "Examples" }} {{ $heading := dict "level" 2 "text" "Examples" }}
{{ partial "heading.html" $heading }} {{ partial "heading.html" $heading }}
@ -166,6 +169,28 @@
{{ end }} {{ end }}
{{ $.RenderString (dict "display" "block") . }} {{ $.RenderString (dict "display" "block") . }}
{{ end }} {{ end }}
{{ if eq .Kind "section" }}
{{ $heading := dict "level" 2 "text" "Subcommands" }}
{{ partial "heading.html" $heading }}
{{ $.Scratch.Add "headings" $heading }}
<table>
<thead>
<tr>
<th class="text-left">Command</th>
<th class="text-left">Description</th>
</tr>
</thead>
<tbody>
{{ range .Pages }}
<tr>
<td class="text-left"><a class="link" href="{{ .Permalink }}"><code>{{ .Title }}</code></a></th>
{{ $data := index (index site.Data .Params.datafolder) .Params.datafile }}
<td class="text-left">{{ $data.short }}</th>
</tr>
{{ end }}
</tbody>
</table>
{{ end }}
</article> </article>
{{ end }} {{ end }}