github.com/Jeffail/benthos/v3@v3.65.0/internal/template/docs.go (about) 1 package template 2 3 import ( 4 "bytes" 5 "text/template" 6 7 "github.com/Jeffail/benthos/v3/internal/docs" 8 9 _ "embed" 10 ) 11 12 //go:embed docs.md 13 var templateDocs string 14 15 type templateContext struct { 16 Fields []docs.FieldSpecCtx 17 } 18 19 // DocsMarkdown returns a markdown document for the templates documentation. 20 func DocsMarkdown() ([]byte, error) { 21 templateDocsTemplate := docs.FieldsTemplate(false) + templateDocs 22 23 var buf bytes.Buffer 24 err := template.Must(template.New("templates").Parse(templateDocsTemplate)).Execute(&buf, templateContext{ 25 Fields: docs.FieldCommon("", "").WithChildren(ConfigSpec()...).FlattenChildrenForDocs(), 26 }) 27 28 return buf.Bytes(), err 29 }