forked from hairyhenderson/gomplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
func_doc.md.tmpl
59 lines (49 loc) · 1.56 KB
/
func_doc.md.tmpl
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
{{ define "argName" }}{{ if not .required }}[{{ .name }}]{{else}}{{ .name }}{{end}}{{ end }}
{{- define "usage" }}### Usage
{{- $arguments := index . "arguments" | default slice }}
{{ if has . "rawUsage" }}{{ .rawUsage | strings.TrimSpace }}{{ else }}
```go
{{ .name }}{{ range $a := $arguments }} {{template "argName" $a }}{{end}}
```
{{- if (index . "pipeline" | default false) }}
```go
{{ $last := (sub (len $arguments) 1) -}}
{{ (index $arguments $last).name }} | {{ .name }}{{ range $i, $a := $arguments }}{{if not (eq $i $last)}} {{template "argName" $a }}{{end}}{{end}}
```
{{- end }}{{ end -}}
{{ end -}}
{{ $data := ds "data" -}}
---
title: {{ index $data "title" | default (print $data.ns " functions") }}
menu:
main:
parent: functions
---
{{ $data.preamble -}}
{{ range $_, $f := $data.funcs }}
## {{ if has $f "rawName" }}{{ $f.rawName }}{{ else }}`{{ $f.name }}`{{ if has $f "deprecated" }} _(deprecated)_
**Deprecation Notice:** {{ $f.deprecated }}{{ end }}{{ end }}
{{ if has $f "alias" }}
**Alias:** `{{$f.alias}}`
{{ end }}
{{- if has $f "description" }}
{{ $f.description }}
{{ end -}}
{{ template "usage" $f }}
{{ if has $f "arguments" -}}
### Arguments
| name | description |
|------|-------------|
{{ range $f.arguments }}| `{{.name}}` | _({{if .required}}required{{else}}optional{{end}})_ {{.description}} |
{{ end }}
{{- end -}}
{{if has $f "examples" }}
### Examples
{{ range $f.examples -}}
```console
{{ . | strings.TrimSpace }}
```
{{ end }}{{ end -}}
{{ if has $f "rawExamples" }}
### Examples
{{ range $f.rawExamples }}{{ . }}{{ end }}{{ end }}{{ end -}}