docs

package
v3.8.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: MIT Imports: 6 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

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

	Fields FieldSpecs
}

ComponentSpec describes a Benthos component.

func (*ComponentSpec) AsMarkdown

func (c *ComponentSpec) AsMarkdown(fullConfigExample interface{}) ([]byte, error)

AsMarkdown renders the spec of a component, along with a full configuration example, into a markdown document.

type FieldSpec

type FieldSpec struct {
	// 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

	// Examples is a slice of optional example values for a field.
	Examples []interface{}
}

FieldSpec describes a component config field.

func FieldAdvanced

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

FieldAdvanced returns a field spec for an advanced field.

func FieldCommon

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

FieldCommon returns a field spec for a common field.

func FieldDeprecated

func FieldDeprecated() FieldSpec

FieldDeprecated returns a field spec for a deprecated field.

type FieldSpecs

type FieldSpecs map[string]FieldSpec

FieldSpecs is a map of field specs for a component.

func (FieldSpecs) ConfigAdvanced

func (f FieldSpecs) ConfigAdvanced(config map[string]interface{}) map[string]interface{}

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 map[string]interface{}) map[string]interface{}

ConfigCommon takes a sanitised configuration of a component, a map of field docs, and removes all fields that aren't common or are deprecated.

Jump to

Keyboard shortcuts

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