Skip to content

Commit 8c05ef7

Browse files
committed
hugo: render markdown for api/cli reference pages
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
1 parent 8fb9d3a commit 8c05ef7

2 files changed

Lines changed: 129 additions & 0 deletions

File tree

layouts/_default/api.markdown.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: {{ .Title }}
3+
url: {{ .Permalink }}
4+
{{- range .Ancestors }}
5+
{{- if and (not .IsHome) .Permalink }}
6+
parent:
7+
title: {{ .Title }}
8+
url: {{ .Permalink }}
9+
{{- break }}
10+
{{- end }}
11+
{{- end }}
12+
{{- if .Ancestors }}
13+
breadcrumbs:
14+
{{- range .Ancestors.Reverse }}
15+
{{- if and (not .IsHome) .Permalink }}
16+
- title: {{ .Title }}
17+
url: {{ .Permalink }}
18+
{{- end }}
19+
{{- end }}
20+
- title: {{ .Title }}
21+
url: {{ .Permalink }}
22+
{{- end }}
23+
{{- with .NextInSection }}
24+
next:
25+
title: {{ .Title }}
26+
url: {{ .Permalink }}
27+
{{- end }}
28+
{{- with .PrevInSection }}
29+
prev:
30+
title: {{ .Title }}
31+
url: {{ .Permalink }}
32+
{{- end }}
33+
{{- $specURL := urls.Parse (printf "/%s%s.yaml" .File.Dir .File.ContentBaseName) }}
34+
openapi_spec: {{ $specURL.String | absURL }}
35+
---
36+
37+
{{ .Content }}
38+
39+
**OpenAPI Specification:** [{{ .Title }} API Spec]({{ $specURL.String | absURL }})
40+
41+
This page provides interactive API documentation. For the machine-readable OpenAPI specification, see the link above.

layouts/_default/cli.markdown.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{{- $data := "" }}
2+
{{- if .Params.datafolder }}
3+
{{- $data = index (index site.Data .Params.datafolder) .Params.datafile }}
4+
{{- else }}
5+
{{- $data = index site.Data .Params.datafile }}
6+
{{- end -}}
7+
---
8+
title: {{ .Title }}
9+
url: {{ .Permalink }}
10+
{{- range .Ancestors }}
11+
{{- if and (not .IsHome) .Permalink }}
12+
parent:
13+
title: {{ .Title }}
14+
url: {{ .Permalink }}
15+
{{- break }}
16+
{{- end }}
17+
{{- end }}
18+
{{- if .Ancestors }}
19+
breadcrumbs:
20+
{{- range .Ancestors.Reverse }}
21+
{{- if and (not .IsHome) .Permalink }}
22+
- title: {{ .Title }}
23+
url: {{ .Permalink }}
24+
{{- end }}
25+
{{- end }}
26+
- title: {{ .Title }}
27+
url: {{ .Permalink }}
28+
{{- end }}
29+
{{- with .NextInSection }}
30+
next:
31+
title: {{ .Title }}
32+
url: {{ .Permalink }}
33+
{{- end }}
34+
{{- with .PrevInSection }}
35+
prev:
36+
title: {{ .Title }}
37+
url: {{ .Permalink }}
38+
{{- end }}
39+
---
40+
41+
{{ with $data.short }}**Description:** {{ . }}{{ end }}
42+
43+
{{ with $data.usage }}**Usage:** `{{ . }}`{{ end }}
44+
45+
{{ with $data.aliases }}{{ $aliases := strings.Replace . (printf "%s, " $.Title) "" }}**Aliases:** {{ range $i, $alias := (strings.Split $aliases ", ") }}{{ if $i }}, {{ end }}`{{ $alias }}`{{ end }}{{ end }}
46+
47+
{{ .Content }}
48+
49+
{{ if $data.deprecated }}> [!WARNING]
50+
> **Deprecated**
51+
>
52+
> This command is deprecated. It may be removed in a future Docker version.
53+
{{ end }}
54+
55+
{{ if or $data.experimental $data.experimentalcli }}> [!NOTE]
56+
> **Experimental**
57+
>
58+
> This command is experimental. Experimental features are intended for testing and feedback as their functionality or design may change between releases without warning or can be removed entirely in a future release.
59+
{{ end }}
60+
61+
{{ with $data.kubernetes }}**Orchestrator:** Kubernetes{{ end }}
62+
{{ with $data.swarm }}**Orchestrator:** Swarm{{ end }}
63+
64+
{{ with $data.long }}## Description
65+
66+
{{ . }}
67+
{{ end }}
68+
69+
{{ with $data.options }}{{ $opts := where . "hidden" false }}{{ with $opts }}## Options
70+
71+
| Option | Default | Description |
72+
|--------|---------|-------------|
73+
{{ range . }}{{ $short := .shorthand }}{{ $long := .option }}| {{ with $short }}`-{{ . }}`, {{ end }}`--{{ $long }}` | {{ with .default_value }}{{ $skipDefault := `[],map[],false,0,0s,default,'',""` }}{{ cond (in $skipDefault .) "" (printf "`%s`" .) }}{{ end }} | {{ with .min_api_version }}API {{ . }}+{{ end }}{{ with .deprecated }} **Deprecated**{{ end }}{{ with .experimental }} **experimental (daemon)**{{ end }}{{ with .experimentalcli }} **experimental (CLI)**{{ end }}{{ with .kubernetes }} **Kubernetes**{{ end }}{{ with .swarm }} **Swarm**{{ end }}{{ if .description }} {{ strings.Replace .description "\n" "<br>" }}{{ end }} |
74+
{{ end }}
75+
{{ end }}{{ end }}
76+
77+
{{ with $data.examples }}## Examples
78+
79+
{{ . }}
80+
{{ end }}
81+
82+
{{ if eq .Kind "section" }}## Subcommands
83+
84+
| Command | Description |
85+
|---------|-------------|
86+
{{ range .Pages }}{{ if and .Params.datafolder .Params.datafile }}{{ $subdata := index (index site.Data .Params.datafolder) .Params.datafile }}| [`{{ .Title }}`]({{ .Permalink }}) | {{ $subdata.short }} |
87+
{{ end }}{{ end }}
88+
{{ end }}

0 commit comments

Comments
 (0)