github.com/wuhuizuo/gomplate@v3.5.0+incompatible/docs-src/content/functions/func_doc.md.tmpl (about) 1 {{ define "argName" }}{{ if not .required }}[{{ .name }}]{{else}}{{ .name }}{{end}}{{ end }} 2 3 {{- define "usage" }}### Usage 4 {{- $arguments := index . "arguments" | default slice }} 5 {{ if has . "rawUsage" }}{{ .rawUsage | strings.TrimSpace }}{{ else }} 6 ```go 7 {{ .name }}{{ range $a := $arguments }} {{template "argName" $a }}{{end}} 8 ``` 9 {{- if (index . "pipeline" | default false) }} 10 ```go 11 {{ $last := (sub (len $arguments) 1) -}} 12 {{ (index $arguments $last).name }} | {{ .name }}{{ range $i, $a := $arguments }}{{if not (eq $i $last)}} {{template "argName" $a }}{{end}}{{end}} 13 ``` 14 {{- end }}{{ end -}} 15 {{ end -}} 16 17 {{ $data := ds "data" -}} 18 --- 19 title: {{ index $data "title" | default (print $data.ns " functions") }} 20 menu: 21 main: 22 parent: functions 23 --- 24 25 {{ $data.preamble -}} 26 27 {{ range $_, $f := $data.funcs }} 28 ## {{ if has $f "rawName" }}{{ $f.rawName }}{{ else }}`{{ $f.name }}`{{ if has $f "deprecated" }} _(deprecated)_ 29 **Deprecation Notice:** {{ $f.deprecated }}{{ end }}{{ end }} 30 {{ if has $f "alias" }} 31 **Alias:** `{{$f.alias}}` 32 {{ end }} 33 34 {{- if has $f "description" }} 35 {{ $f.description }} 36 {{ end -}} 37 38 {{ template "usage" $f }} 39 40 {{ if has $f "arguments" -}} 41 ### Arguments 42 43 | name | description | 44 |------|-------------| 45 {{ range $f.arguments }}| `{{.name}}` | _({{if .required}}required{{else}}optional{{end}})_ {{.description}} | 46 {{ end }} 47 {{- end -}} 48 {{if has $f "examples" }} 49 ### Examples 50 51 {{ range $f.examples -}} 52 ```console 53 {{ . | strings.TrimSpace }} 54 ``` 55 {{ end }}{{ end -}} 56 {{ if has $f "rawExamples" }} 57 ### Examples 58 59 {{ range $f.rawExamples }}{{ . }}{{ end }}{{ end }}{{ end -}}