renderer

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderSchema

func RenderSchema(schema *types.Schema, r Renderer) []string

RenderStrings builds a string representation of a type result using the given pre, path, and post functions.

func RenderType

func RenderType(t *types.TypeNode, r Renderer) []string

RenderType builds strings for a TypeNode and its children.

Types

type Options

type Options struct {
	// DeReference converts TypeRef to their included types.
	// - If TyepRefs have a cyclical relationship, the last TypeRef is kept as a TypeRef.
	DeReference bool

	// Dialects uses dialect resolution to override defaults.
	// - May be overridden or ignored by renderers.
	Dialects []string

	// IncludeNative includes details on native types if set.
	// - May be overridden or ignored by renderers.
	IncludeNative bool

	// Prefix is a string used as a prefix for indented lines.
	Prefix string

	// Indent is used for rendering where indent matters.
	Indent int
}

func NewOptions

func NewOptions() *Options

type Renderer

type Renderer interface {
	// ProcessResult starts the render process on a Schema and returns a slice of strings.
	// - settings is one or more strings with options for specific processors.
	ProcessSchema(schema *types.Schema, settings ...string) ([]string, error)

	// DeReference returns true if schema references should be replaced with inline types.
	DeReference() bool

	// Indent returns the current indent value.
	Indent() int

	// SetIndent sets the indent to a given value.
	SetIndent(value int)

	// Prefix returns a prefix string with the current indent.
	Prefix() string

	// NativeType returns the native type for the renderer.
	NativeType(t *types.TypeNode) *types.NativeType

	// Pre and Post return strings before/after a type element's children are processed.
	Pre(t *types.TypeNode) []string
	Post(t *types.TypeNode) []string

	// Path is a function that builds a path string from a TypeNode.
	Path(t *types.TypeNode) []string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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