renderers

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DocTypesMode

type DocTypesMode int

DocTypesMode defines rendering modes for field types in JSONC comments.

const (
	NoFields    DocTypesMode = iota // Don't show type on all fields (default).
	AllFields                       // Show types for all fields.
	BasicFields                     // Show types for basic fields only (int, float, bool, string).
)

type Interface

type Interface interface {
	// RenderStruct renders indented code for specified struct and all nested or embedded ones recursively.
	RenderStruct(info *distiller.StructInfo, defaults interface{}, indent string,
		embedded bool, parentShadowing []string) (string, error)
	// RenderArray renders slice or array fields.
	RenderArray(field *distiller.FieldInfo, value []interface{}, indent string) (string, error)
	// RenderMap renders map fields.
	RenderMap(field *distiller.FieldInfo, value *ordered.Map, indent string) (string, error)
	// RenderElement renders an element value of a slice, array or map.
	RenderElement(itemType types.Type, item interface{}, indent string) (string, error)
}

Interface defines a renderer interface.

type Jsonc

type Jsonc struct {
	// contains filtered or unexported fields
}

Jsonc renders JSONC code from distiller info.

func NewJsonc

func NewJsonc(mode DocTypesMode) *Jsonc

NewJsonc creates a new JSONC renderer. mode controls the rendering of field types in JSONC comments.

func (*Jsonc) RenderArray

func (j *Jsonc) RenderArray(field *distiller.FieldInfo, value []interface{}, indent string) (string, error)

func (*Jsonc) RenderElement

func (j *Jsonc) RenderElement(itemType types.Type, item interface{}, indent string) (string, error)

func (*Jsonc) RenderMap

func (j *Jsonc) RenderMap(field *distiller.FieldInfo, value *ordered.Map, indent string) (string, error)

func (*Jsonc) RenderStruct

func (j *Jsonc) RenderStruct(info *distiller.StructInfo, defaults interface{}, indent string,
	embedded bool, parentShadowing []string) (string, error)

type Toml

type Toml struct {
	// contains filtered or unexported fields
}

Toml renders Toml code from distiller info.

func NewToml

func NewToml(mode DocTypesMode, indented bool) *Toml

NewToml creates a new Toml renderer. mode controls the rendering of field types in Toml comments.

func (*Toml) RenderArray

func (t *Toml) RenderArray(field *distiller.FieldInfo, value []interface{}, indent string) (string, error)

func (*Toml) RenderElement

func (t *Toml) RenderElement(itemType types.Type, item interface{}, indent string) (string, error)

func (*Toml) RenderMap

func (t *Toml) RenderMap(field *distiller.FieldInfo, value *ordered.Map, indent string) (string, error)

func (*Toml) RenderStruct

func (t *Toml) RenderStruct(info *distiller.StructInfo, defaults interface{}, indent string, embedded bool, _ []string) (string, error)

Jump to

Keyboard shortcuts

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