Documentation
¶
Overview ¶
Package docs provides useful functions for creating documentation from Benthos components
Index ¶
- func BloblangFunctionsMarkdown() ([]byte, error)
- func BloblangMethodsMarkdown() ([]byte, error)
- type AnnotatedExample
- type ComponentSpec
- type FieldInterpolation
- type FieldSpec
- func (f FieldSpec) AtVersion(v string) FieldSpec
- func (f FieldSpec) HasAnnotatedOptions(options ...string) FieldSpec
- func (f FieldSpec) HasDefault(v interface{}) FieldSpec
- func (f FieldSpec) HasOptions(options ...string) FieldSpec
- func (f FieldSpec) HasType(t FieldType) FieldSpec
- func (f FieldSpec) SupportsInterpolation(batchWide bool) FieldSpec
- func (f FieldSpec) WithChildren(children ...FieldSpec) FieldSpec
- type FieldSpecs
- func (f FieldSpecs) Add(specs ...FieldSpec) FieldSpecs
- func (f FieldSpecs) ConfigAdvanced(config interface{}) (interface{}, error)
- func (f FieldSpecs) ConfigCommon(config interface{}) (interface{}, error)
- func (f FieldSpecs) Merge(specs FieldSpecs) FieldSpecs
- func (f FieldSpecs) RemoveDeprecated(s config.Sanitised)
- type FieldType
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BloblangFunctionsMarkdown ¶ added in v3.26.0
BloblangFunctionsMarkdown returns a markdown document for all Bloblang functions.
func BloblangMethodsMarkdown ¶ added in v3.26.0
BloblangMethodsMarkdown returns a markdown document for all Bloblang methods.
Types ¶
type AnnotatedExample ¶ added in v3.25.0
type AnnotatedExample struct {
// A title for the example.
Title string
// Summary of the example.
Summary string
// A config snippet to show.
Config string
}
AnnotatedExample is an isolated example for a component.
type ComponentSpec ¶
type ComponentSpec struct {
// Name of the component
Name string
// Type of the component (input, output, etc)
Type string
// The status of the component.
Status Status
// Summary of the component (in markdown, must be short).
Summary string
// Description of the component (in markdown).
Description string
// Categories that describe the purpose of the component.
Categories []string
// Footnotes of the component (in markdown).
Footnotes string
// Examples demonstrating use cases for the component.
Examples []AnnotatedExample
Fields FieldSpecs
// Version is the Benthos version this component was introduced.
Version string
}
ComponentSpec describes a Benthos component.
func (*ComponentSpec) AsMarkdown ¶
func (c *ComponentSpec) AsMarkdown(nest bool, fullConfigExample interface{}) ([]byte, error)
AsMarkdown renders the spec of a component, along with a full configuration example, into a markdown document.
type FieldInterpolation ¶
type FieldInterpolation int
FieldInterpolation represents a type of interpolation supported by a field.
const ( FieldInterpolationNone FieldInterpolation = iota FieldInterpolationBatchWide FieldInterpolationIndividual )
Interpolation types.
type FieldSpec ¶
type FieldSpec struct {
// Name of the field (as it appears in config).
Name string
// Description of the field purpose (in markdown).
Description string
// Advanced is true for optional fields that will not be present in most
// configs.
Advanced bool
// Deprecated is true for fields that are deprecated and only exist for
// backwards compatibility reasons.
Deprecated bool
// Default value of the field. If left nil the docs generator will attempt
// to infer the default value from an example config.
Default interface{}
// Type of the field. This is optional and doesn't prevent documentation for
// a field.
Type FieldType
// Interpolation indicates the type of interpolation that this field
// supports.
Interpolation FieldInterpolation
// Examples is a slice of optional example values for a field.
Examples []interface{}
// AnnotatedOptions for this field. Each option should have a summary.
AnnotatedOptions [][2]string
// Options for this field.
Options []string
// Children fields of this field (it must be an object).
Children FieldSpecs
// Version lists an explicit Benthos release where this fields behaviour was last modified.
Version string
}
FieldSpec describes a component config field.
func FieldAdvanced ¶
FieldAdvanced returns a field spec for an advanced field.
func FieldCommon ¶
FieldCommon returns a field spec for a common field.
func FieldDeprecated ¶
FieldDeprecated returns a field spec for a deprecated field.
func (FieldSpec) AtVersion ¶ added in v3.34.0
AtVersion specifies the version at which this fields behaviour was last modified.
func (FieldSpec) HasAnnotatedOptions ¶ added in v3.33.0
HasAnnotatedOptions returns a new FieldSpec that specifies a specific list of annotated options. Either
func (FieldSpec) HasDefault ¶ added in v3.28.0
HasDefault returns a new FieldSpec that specifies a default value.
func (FieldSpec) HasOptions ¶
HasOptions returns a new FieldSpec that specifies a specific list of options.
func (FieldSpec) SupportsInterpolation ¶
SupportsInterpolation returns a new FieldSpec that specifies whether it supports function interpolation (batch wide or not).
func (FieldSpec) WithChildren ¶
WithChildren returns a new FieldSpec that has child fields.
type FieldSpecs ¶
type FieldSpecs []FieldSpec
FieldSpecs is a slice of field specs for a component.
func (FieldSpecs) Add ¶
func (f FieldSpecs) Add(specs ...FieldSpec) FieldSpecs
Add more field specs.
func (FieldSpecs) ConfigAdvanced ¶
func (f FieldSpecs) ConfigAdvanced(config interface{}) (interface{}, error)
ConfigAdvanced takes a sanitised configuration of a component, a map of field docs, and removes all fields that are deprecated.
func (FieldSpecs) ConfigCommon ¶
func (f FieldSpecs) ConfigCommon(config interface{}) (interface{}, error)
ConfigCommon takes a sanitised configuration of a component, a map of field docs, and removes all fields that aren't common or are deprecated.
func (FieldSpecs) Merge ¶
func (f FieldSpecs) Merge(specs FieldSpecs) FieldSpecs
Merge with another set of FieldSpecs.
func (FieldSpecs) RemoveDeprecated ¶ added in v3.33.0
func (f FieldSpecs) RemoveDeprecated(s config.Sanitised)
RemoveDeprecated fields from a sanitized config.
type FieldType ¶ added in v3.28.0
type FieldType string
FieldType represents a field type.
var ( FieldString FieldType = "string" FieldNumber FieldType = "number" FieldBool FieldType = "bool" FieldArray FieldType = "array" FieldObject FieldType = "object" FieldUnknown FieldType = "unknown" )
ValueType variants.
func GetFieldType ¶ added in v3.28.0
func GetFieldType(v interface{}) FieldType
GetFieldType attempts to extract a field type from a general value.