docs

package
v3.12.0-rc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package docs provides useful functions for creating documentation from Benthos components

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComponentSpec

type ComponentSpec struct {
	// Name of the component
	Name string

	// Type of the component (input, output, etc)
	Type string

	// Summary of the component (in markdown, must be short).
	Summary string

	// Description of the component (in markdown).
	Description string

	// Footnotes of the component (in markdown).
	Footnotes string

	Fields FieldSpecs
}

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 added in v3.9.0

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

	// Type of the field. This is optional and doesn't prevent documentation for
	// a field.
	Type string

	// 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{}

	// Options for this field.
	Options []string

	// Children fields of this field (it must be an object).
	Children FieldSpecs
}

FieldSpec describes a component config field.

func FieldAdvanced

func FieldAdvanced(name, description string, examples ...interface{}) FieldSpec

FieldAdvanced returns a field spec for an advanced field.

func FieldCommon

func FieldCommon(name, description string, examples ...interface{}) FieldSpec

FieldCommon returns a field spec for a common field.

func FieldDeprecated

func FieldDeprecated(name string) FieldSpec

FieldDeprecated returns a field spec for a deprecated field.

func (FieldSpec) HasOptions added in v3.9.0

func (f FieldSpec) HasOptions(options ...string) FieldSpec

HasOptions returns a new FieldSpec that specifies a specific list of options.

func (FieldSpec) HasType added in v3.9.0

func (f FieldSpec) HasType(typeStr string) FieldSpec

HasType returns a new FieldSpec that specifies a specific type.

func (FieldSpec) SupportsInterpolation added in v3.9.0

func (f FieldSpec) SupportsInterpolation(batchWide bool) FieldSpec

SupportsInterpolation returns a new FieldSpec that specifies whether it supports function interpolation (batch wide or not).

func (FieldSpec) WithChildren added in v3.9.0

func (f FieldSpec) WithChildren(children ...FieldSpec) FieldSpec

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 added in v3.9.0

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 added in v3.9.0

func (f FieldSpecs) Merge(specs FieldSpecs) FieldSpecs

Merge with another set of FieldSpecs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL