From 3dbc3f5a23a85858b6ebde366fd24b98d2e3868b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Henning?= <soeren.henning@email.uni-kiel.de> Date: Fri, 17 Dec 2021 16:44:33 +0100 Subject: [PATCH] Add template and use crdoc v0.5.1 --- docs/README.md | 2 +- docs/api-reference/crds.tmpl | 104 +++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 docs/api-reference/crds.tmpl diff --git a/docs/README.md b/docs/README.md index 3da3a7d1a..009e37516 100644 --- a/docs/README.md +++ b/docs/README.md @@ -39,5 +39,5 @@ crdoc --resources ../theodolite/crd/ --output api-reference/crds.md With the following command, crdoc is installed and executed in Docker: ```sh -docker run --rm -v "`pwd`/../theodolite/crd/":/crd -v "`pwd`/api-reference":/api-reference golang sh -c "go install fybrik.io/crdoc@latest && crdoc --resources /crd/ --output /api-reference/crds.md" +docker run --rm -v "`pwd`/../theodolite/crd/":/crd -v "`pwd`/api-reference":/api-reference golang sh -c "go install fybrik.io/crdoc@v0.5.1 && crdoc --resources /crd/ --template /api-reference/crds.tmpl --output /api-reference/crds.md" ``` diff --git a/docs/api-reference/crds.tmpl b/docs/api-reference/crds.tmpl new file mode 100644 index 000000000..3f642f371 --- /dev/null +++ b/docs/api-reference/crds.tmpl @@ -0,0 +1,104 @@ +--- +title: Theodolite CRDs +has_children: false +parent: API Reference +nav_order: 1 +--- + + +# API Reference + +Packages: +{{range .Groups}} +- [{{.Group}}/{{.Version}}](#{{ anchorize (printf "%s/%s" .Group .Version) }}) +{{- end -}}{{/* range .Groups */}} + +{{- range .Groups }} +{{- $group := . }} + +# {{.Group}}/{{.Version}} + +Resource Types: +{{range .Kinds}} +- [{{.Name}}](#{{ anchorize .Name }}) +{{end}}{{/* range .Kinds */}} + +{{range .Kinds}} +{{$kind := .}} +## {{.Name}} +<sup><sup>[↩ Parent](#{{ anchorize (printf "%s/%s" $group.Group $group.Version) }} )</sup></sup> + +{{range .Types}} + +{{if not .IsTopLevel}} +### {{.Name}} +{{if .ParentKey}}<sup><sup>[↩ Parent](#{{.ParentKey}})</sup></sup>{{end}} +{{end}} + + +{{.Description}} + +<table> + <thead> + <tr> + <th>Name</th> + <th>Type</th> + <th>Description</th> + <th>Required</th> + </tr> + </thead> + <tbody> + {{- if .IsTopLevel -}} + <tr> + <td><b>apiVersion</b></td> + <td>string</td> + <td>{{$group.Group}}/{{$group.Version}}</td> + <td>true</td> + </tr> + <tr> + <td><b>kind</b></td> + <td>string</td> + <td>{{$kind.Name}}</td> + <td>true</td> + </tr> + <tr> + <td><b><a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#objectmeta-v1-meta">metadata</a></b></td> + <td>object</td> + <td>Refer to the Kubernetes API documentation for the fields of the `metadata` field.</td> + <td>true</td> + </tr> + {{- end -}} + {{- range .Fields -}} + <tr> + <td><b>{{if .TypeKey}}<a href="#{{.TypeKey}}">{{.Name}}</a>{{else}}{{.Name}}{{end}}</b></td> + <td>{{.Type}}</td> + <td> + {{.Description}}<br/> + {{- if or .Schema.Format .Schema.Enum .Schema.Default .Schema.Minimum .Schema.Maximum }} + <br/> + {{- end}} + {{- if .Schema.Format }} + <i>Format</i>: {{ .Schema.Format }}<br/> + {{- end }} + {{- if .Schema.Enum }} + <i>Enum</i>: {{ .Schema.Enum | toStrings | join ", " }}<br/> + {{- end }} + {{- if .Schema.Default }} + <i>Default</i>: {{ .Schema.Default }}<br/> + {{- end }} + {{- if .Schema.Minimum }} + <i>Minimum</i>: {{ .Schema.Minimum }}<br/> + {{- end }} + {{- if .Schema.Maximum }} + <i>Maximum</i>: {{ .Schema.Maximum }}<br/> + {{- end }} + </td> + <td>{{.Required}}</td> + </tr> + {{- end -}} + </tbody> +</table> + +{{- end}}{{/* range .Types */}} +{{- end}}{{/* range .Kinds */}} +{{- end}}{{/* range .Groups */}} \ No newline at end of file -- GitLab