Documentation
¶
Index ¶
- Variables
- func DefaultLookupCommentFunc(commentMap map[string]string) func(t reflect.Type, f string) string
- func MergeRootFromValue(data []byte, v any) ([]byte, error)
- func NewPathBuilder() *yaml.PathBuilder
- type Decoder
- type Encoder
- type Error
- type ErrorOpt
- type ErrorWrapper
- type LookupCommentFunc
- type PrintFunc
- type Printer
- type Property
- type SchemaGenerator
- type Validator
Constants ¶
This section is empty.
Variables ¶
var DefaultEncoderOptions = []yaml.EncodeOption{ yaml.Indent(2), yaml.IndentSequence(true), }
Functions ¶
func MergeRootFromValue ¶ added in v0.28.0
MergeRootFromValue parses YAML data, merges a value at the root, and returns the result. Comments and structure in the original data are preserved.
func NewPathBuilder ¶
func NewPathBuilder() *yaml.PathBuilder
Types ¶
type Error ¶
type Error struct {
Err error
Path *yaml.Path
Token *token.Token
Theme *theme.Theme
Formatter string
Source []byte
SourceLines int // Number of lines to show around the error in the source.
}
Error represents a YAML error. It includes the original error, and the *token.Token where the error occurred.
type ErrorOpt ¶
type ErrorOpt func(e *Error)
func WithFormatter ¶
func WithSource ¶
func WithSourceLines ¶
type ErrorWrapper ¶
type ErrorWrapper struct {
Opts []ErrorOpt
}
func NewErrorWrapper ¶
func NewErrorWrapper(opts ...ErrorOpt) *ErrorWrapper
type LookupCommentFunc ¶
type Printer ¶
type Printer struct {
MapKey PrintFunc
Anchor PrintFunc
Alias PrintFunc
Bool PrintFunc
String PrintFunc
Number PrintFunc
Comment PrintFunc
}
Printer create text from token collection or ast. This is a simplified version of github.com/goccy/go-yaml/printer.Printer, with styling and annotation functionality removed.
func (*Printer) PrintErrorToken ¶
type SchemaGenerator ¶
type SchemaGenerator struct {
Reflector *jsonschema.Reflector
LookupCommentFunc LookupCommentFunc
Tests bool // Include test files.
// contains filtered or unexported fields
}
SchemaGenerator generates a JSON schema from a Go type using reflection. It looks up comments from the source code to provide documentation, one or more package paths are provided. Uses github.com/invopop/jsonschema.
func NewSchemaGenerator ¶
func NewSchemaGenerator(reflectTarget any, packagePaths ...string) *SchemaGenerator
NewSchemaGenerator creates a new SchemaGenerator. The reflectTarget is the Go type to generate the schema for, and packagePaths are the fully qualified import paths of the packages to lookup comments from.
func (*SchemaGenerator) Generate ¶
func (g *SchemaGenerator) Generate() ([]byte, error)
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator validates data against a JSON schema. Uses github.com/santhosh-tekuri/jsonschema/v6.
func MustNewValidator ¶
func NewValidator ¶
NewValidator creates a new Validator with the provided JSON schema data.