export

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var All = &Profile{
	Simplify:        true,
	ShowOptional:    true,
	ShowDefinitions: true,
	ShowHidden:      true,
	ShowDocs:        true,
	ShowAttributes:  true,
	AddPackage:      true,
}
View Source
var Final = &Profile{
	Simplify:     true,
	TakeDefaults: true,
	Final:        true,
}
View Source
var Raw = &Profile{
	ShowOptional:    true,
	ShowDefinitions: true,
	ShowHidden:      true,
	ShowDocs:        true,
	AddPackage:      true,
}
View Source
var Simplified = &Profile{
	Simplify: true,
	ShowDocs: true,
}

Functions

func Def

func Def(r adt.Runtime, pkgID string, v *adt.Vertex) (*ast.File, errors.Error)

Def exports v as a definition. It resolves references that point outside any of the vertices in v.

func Expr

func Expr(r adt.Runtime, pkgID string, n adt.Expr) (ast.Expr, errors.Error)

Expr exports the given unevaluated expression (schema mode). It does not resolve references that point outside the given expression.

func ExtractDeclAttrs

func ExtractDeclAttrs(v *adt.Vertex) (attrs []*ast.Attribute)

func ExtractDoc

func ExtractDoc(v *adt.Vertex) (docs []*ast.CommentGroup)

ExtractDoc collects documentation strings for a field.

Comments are attached to a field with a field shorthand belong to the child node. So in the following the comment is attached to field bar.

// comment
foo: bar: 2

func ExtractFieldAttrs

func ExtractFieldAttrs(v *adt.Vertex) (attrs []*ast.Attribute)

func Value

func Value(r adt.Runtime, pkgID string, n adt.Value) (ast.Expr, errors.Error)

Value exports evaluated values (data mode). It does not resolve references that point outside the given Value.

func Vertex

func Vertex(r adt.Runtime, pkgID string, n *adt.Vertex) (*ast.File, errors.Error)

Vertex exports evaluated values (data mode). It resolves incomplete references that point outside the current context.

func VertexFeatures

func VertexFeatures(c *adt.OpContext, v *adt.Vertex) []adt.Feature

VertexFeatures returns the feature list of v. The list may include more features than for which there are arcs and also includes features for optional fields. It assumes the Structs fields are initialized and evaluated.

Types

type Profile

type Profile struct {
	Simplify bool

	// Final reports incomplete errors as errors.
	Final bool

	// TakeDefaults is used in Value mode to drop non-default values.
	TakeDefaults bool

	ShowOptional    bool
	ShowDefinitions bool

	// ShowHidden forces the inclusion of hidden fields when these would
	// otherwise be omitted. Only hidden fields from the current package are
	// included.
	ShowHidden     bool
	ShowDocs       bool
	ShowAttributes bool

	// ShowErrors treats errors as values and will not percolate errors up.
	//
	// TODO: convert this option to an error level instead, showing only
	// errors below a certain severity.
	ShowErrors bool

	// SelfContained exports a schema such that it does not rely on any imports.
	SelfContained bool

	// Fragment disables printing a value as self contained. To successfully
	// parse a fragment, the compiler needs to be given a scope with the value
	// from which the fragment was extracted.
	Fragment bool

	// AddPackage causes a package clause to be added.
	AddPackage bool

	// InlineImports expands references to non-builtin packages.
	InlineImports bool
}

func (*Profile) Def

func (p *Profile) Def(r adt.Runtime, pkgID string, v *adt.Vertex) (f *ast.File, err errors.Error)

Def exports v as a definition. It resolves references that point outside any of the vertices in v.

func (*Profile) Expr

func (p *Profile) Expr(r adt.Runtime, pkgID string, n adt.Expr) (ast.Expr, errors.Error)

Expr exports the given unevaluated expression (schema mode). It does not resolve references that point outside the given expression.

func (*Profile) Value

func (p *Profile) Value(r adt.Runtime, pkgID string, n adt.Value) (ast.Expr, errors.Error)

Value exports evaluated values (data mode).

It does not resolve references that point outside the given Value.

TODO: Should take context.

func (*Profile) Vertex

func (p *Profile) Vertex(r adt.Runtime, pkgID string, n *adt.Vertex) (f *ast.File, err errors.Error)

Vertex exports evaluated values (data mode). It resolves incomplete references that point outside the current context.

Jump to

Keyboard shortcuts

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