From c04c83ff5825a5010b083932f6418023ef0f5f9c Mon Sep 17 00:00:00 2001
From: David Karlsson <35727626+dvdksn@users.noreply.github.com>
Date: Thu, 29 Feb 2024 15:13:29 +0100
Subject: [PATCH 1/2] cli: don't render options table if only hidden options
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
---
layouts/_default/cli.html | 117 +++++++++++++++++++-------------------
1 file changed, 60 insertions(+), 57 deletions(-)
diff --git a/layouts/_default/cli.html b/layouts/_default/cli.html
index fc0b9809e8..32905f1028 100644
--- a/layouts/_default/cli.html
+++ b/layouts/_default/cli.html
@@ -94,65 +94,68 @@
{{ . | $.RenderString (dict "display" "block") }}
{{ end }}
{{ with $data.options }}
- {{ $heading := dict "level" 2 "text" "Options" }}
- {{ partial "heading.html" $heading }}
- {{ $.Scratch.Add "headings" $heading }}
-
-
-
- Option |
- Default |
- Description |
-
-
-
- {{ range where . "hidden" false }}
+ {{ $opts := where . "hidden" false }}
+ {{ with $opts }}
+ {{ $heading := dict "level" 2 "text" "Options" }}
+ {{ partial "heading.html" $heading }}
+ {{ $.Scratch.Add "headings" $heading }}
+
+
- {{ $short := .shorthand }}
- {{ $long := .option }}
-
- {{ with .details_url }}
-
- {{ with $short }}-{{ . }}, {{end}}--{{ $long }}
-
- {{ else }}
- {{ with $short }}-{{ . }}, {{end}}--{{ $long }}
- {{ end }}
- |
- {{ $skipDefault := `[],map[],false,0,0s,default,'',""` }}
-
- {{ with .default_value }}
- {{ cond (in $skipDefault .) "" (printf "%s " . | safeHTML) }}
- {{ end }}
- |
-
- {{ with .min_api_version }}
- {{ partial "components/badge.html" (dict "color" "blue" "content" (printf "API %s+" .)) }}
- {{ end }}
- {{ with .deprecated }}
- {{ partial "components/badge.html" (dict "color" "red" "content" "Deprecated") }}
- {{ end }}
- {{ with .experimental }}
- {{ partial "components/badge.html" (dict "color" "amber" "content" "experimental (daemon)") }}
- {{ end }}
- {{ with .experimentalcli }}
- {{ partial "components/badge.html" (dict "color" "amber" "content" "experimental (CLI)") }}
- {{ end }}
- {{ with .kubernetes }}
- {{ partial "components/badge.html" (dict "color" "blue" "content" "Kubernetes") }}
- {{ end }}
- {{ with .swarm }}
- {{ partial "components/badge.html" (dict "color" "blue" "content" "Swarm") }}
- {{ end }}
- {{ if .description }}
- {{/* replace newlines in long desc with break tags */}}
- {{ markdownify (strings.Replace .description "\n" " ") }}
- {{ end }}
- |
+ Option |
+ Default |
+ Description |
- {{ end }}
-
-
+
+
+ {{ range . }}
+
+ {{ $short := .shorthand }}
+ {{ $long := .option }}
+
+ {{ with .details_url }}
+
+ {{ with $short }}-{{ . }}, {{end}}--{{ $long }}
+
+ {{ else }}
+ {{ with $short }}-{{ . }}, {{end}}--{{ $long }}
+ {{ end }}
+ |
+ {{ $skipDefault := `[],map[],false,0,0s,default,'',""` }}
+
+ {{ with .default_value }}
+ {{ cond (in $skipDefault .) "" (printf "%s " . | safeHTML) }}
+ {{ end }}
+ |
+
+ {{ with .min_api_version }}
+ {{ partial "components/badge.html" (dict "color" "blue" "content" (printf "API %s+" .)) }}
+ {{ end }}
+ {{ with .deprecated }}
+ {{ partial "components/badge.html" (dict "color" "red" "content" "Deprecated") }}
+ {{ end }}
+ {{ with .experimental }}
+ {{ partial "components/badge.html" (dict "color" "amber" "content" "experimental (daemon)") }}
+ {{ end }}
+ {{ with .experimentalcli }}
+ {{ partial "components/badge.html" (dict "color" "amber" "content" "experimental (CLI)") }}
+ {{ end }}
+ {{ with .kubernetes }}
+ {{ partial "components/badge.html" (dict "color" "blue" "content" "Kubernetes") }}
+ {{ end }}
+ {{ with .swarm }}
+ {{ partial "components/badge.html" (dict "color" "blue" "content" "Swarm") }}
+ {{ end }}
+ {{ if .description }}
+ {{/* replace newlines in long desc with break tags */}}
+ {{ markdownify (strings.Replace .description "\n" " ") }}
+ {{ end }}
+ |
+
+ {{ end }}
+
+
+ {{ end }}
{{ end }}
{{ with $data.examples }}
{{ $heading := dict "level" 2 "text" "Examples" }}
From 51c1bedfb14bc5dae49cc9f3f3fb312efd873b54 Mon Sep 17 00:00:00 2001
From: David Karlsson <35727626+dvdksn@users.noreply.github.com>
Date: Thu, 29 Feb 2024 16:08:10 +0100
Subject: [PATCH 2/2] cli: add subcommand links
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
---
layouts/_default/cli.html | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/layouts/_default/cli.html b/layouts/_default/cli.html
index 32905f1028..cf989b2367 100644
--- a/layouts/_default/cli.html
+++ b/layouts/_default/cli.html
@@ -169,6 +169,28 @@
{{ end }}
{{ $.RenderString (dict "display" "block") . }}
{{ end }}
+ {{ if eq .Kind "section" }}
+ {{ $heading := dict "level" 2 "text" "Subcommands" }}
+ {{ partial "heading.html" $heading }}
+ {{ $.Scratch.Add "headings" $heading }}
+
+
+
+ Command |
+ Description |
+
+
+
+ {{ range .Pages }}
+
+ {{ .Title }}
+ {{ $data := index (index site.Data .Params.datafolder) .Params.datafile }}
+ | {{ $data.short }}
+ |
+ {{ end }}
+
+
+ {{ end }}
{{ end }}