Jonathan Neal d8b67f8520
📌 Hard Pin Website Dependencies (#9543)
* Update and pin dependencies
* Update NextJS Scripts
* npm run lint
* npm run format
* docs generator: indent docs by two and make spacing better

Co-authored-by: Adrien Delorme <azr@users.noreply.github.com>
2020-07-13 12:33:16 +02:00

38 lines
778 B
Go

package main
import (
"strings"
"text/template"
)
type Field struct {
Name string
Type string
Docs string
}
type Struct struct {
SourcePath string
Name string
Filename string
Header string
Fields []Field
}
var structDocsTemplate = template.Must(template.New("structDocsTemplate").
Funcs(template.FuncMap{
"indent": indent,
}).
Parse(`<!-- Code generated from the comments of the {{ .Name }} struct in {{ .SourcePath }}; DO NOT EDIT MANUALLY -->
{{ if .Header }}
{{ .Header }}
{{ end -}}
{{ range .Fields }}
- ` + "`" + `{{ .Name}}` + "`" + ` ({{ .Type }}) - {{ .Docs | indent 2 }}
{{ end }}`))
func indent(spaces int, v string) string {
pad := strings.Repeat(" ", spaces)
return strings.TrimSpace(strings.Replace(v, "\n", "\n"+pad, -1))
}