-
Notifications
You must be signed in to change notification settings - Fork 151
/
tpl.go
72 lines (53 loc) · 1.44 KB
/
tpl.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package docgen
const tplStr = `
{{- define "namespace" -}}
{{ template "do_not_edit" }}
# Documentation for {{ bq }}scw {{ .Cmd.Namespace }}{{ bq }}
{{ remove_escape_sequence (.Cmd.Long | default .Cmd.Short) }}
{{ range $resourceName, $resource := .Resources -}}
- [{{ $resource.Cmd.Short }}](#{{ anchor $resource.Cmd.Short }})
{{- range $verbName, $cmd := $resource.Verbs }}
- [{{ $cmd.Short }}](#{{ anchor $cmd.Short }})
{{- end }}
{{ end }}
{{ range $resourceName, $resource := .Resources -}}
## {{ $resource.Cmd.Short }}
{{ $resource.Cmd.Long }}
{{ if $resource.Verbs | len -}}
{{ range $verbName, $cmd := $resource.Verbs }}
### {{ $cmd.Short }}
{{ template "cmd" (map "Cmd" $cmd "Data" $) }}
{{ end -}}
{{- else -}}
{{ template "cmd" (map "Cmd" $resource.Cmd "Data" $) }}
{{ end }}
{{ end }}
{{- end -}}
{{- define "cmd" -}}
{{ .Cmd.Long }}
**Usage:**
{{ bbq }}
{{ .Cmd.GetUsage "scw" .Data.Commands }}
{{ bbq }}
{{ if .Cmd.ArgSpecs }}
**Args:**
| Name | | Description |
|------|---|-------------|
{{ range $arg := .Cmd.ArgSpecs -}}
| {{ arg_spec_name $arg }} | {{ arg_spec_flag $arg }} | {{ $arg.Short }} |
{{ end -}}
{{- end -}}
{{- if .Cmd.Examples }}
**Examples:**
{{ range $example := .Cmd.Examples }}
{{ $example.Short }}
{{ bbq }}
{{ $example.GetCommandLine "scw" $.Cmd }}
{{ bbq }}
{{ end }}
{{ end }}
{{- end -}}
{{- define "do_not_edit" -}}
<!-- DO NOT EDIT: this file is automatically generated using scw-doc-gen -->
{{- end -}}
`