generator

package
v0.55.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render added in v0.47.0

func Render(opts Options) ([]byte, error)

Render will render file and out it's content.

Types

type GetOptionSpecRes added in v0.48.0

type GetOptionSpecRes struct {
	Spec     OptionSpec
	Warnings []string
	Imports  []Import
}

func GetOptionSpec

func GetOptionSpec(
	filePath, optStructName, tagName string,
	allVariadic bool,
	excludes []*regexp.Regexp,
) (*GetOptionSpecRes, error)

GetOptionSpec read the input filename by filePath, find optionsStructName and scan for options.

type Import added in v0.53.0

type Import struct {
	Path  string
	Alias *string
}

type OptOptionsSetter added in v0.47.0

type OptOptionsSetter func(o *Options)

func WithConstructorTypeRender added in v0.47.0

func WithConstructorTypeRender(opt string) OptOptionsSetter

func WithFileImports added in v0.47.0

func WithFileImports(opt []Import) OptOptionsSetter

func WithFuncName added in v0.47.0

func WithFuncName(opt string) OptOptionsSetter

func WithOptionTypeName added in v0.47.0

func WithOptionTypeName(opt string) OptOptionsSetter

func WithOptionsStructName added in v0.47.0

func WithOptionsStructName(opt string) OptOptionsSetter

func WithPackageName added in v0.47.0

func WithPackageName(opt string) OptOptionsSetter

func WithPrefix added in v0.47.0

func WithPrefix(opt string) OptOptionsSetter

func WithSpec added in v0.47.0

func WithSpec(opt *OptionSpec) OptOptionsSetter

func WithTagName added in v0.47.0

func WithTagName(opt string) OptOptionsSetter

func WithVarName added in v0.47.0

func WithVarName(opt string) OptOptionsSetter

func WithVersion added in v0.47.0

func WithVersion(opt string) OptOptionsSetter

func WithWithIsset added in v0.47.0

func WithWithIsset(opt bool) OptOptionsSetter

type OptionMeta

type OptionMeta struct {
	Name      string
	Docstring string // contains a comment with `//`. Can be empty or contain a multi-line string.
	Field     string
	Type      string
	TagOption TagOption
}

func ApplyExcludes added in v0.55.1

func ApplyExcludes(options []OptionMeta, excludes []*regexp.Regexp) []OptionMeta

type OptionSpec added in v0.15.0

type OptionSpec struct {
	TypeParamsSpec string // [KeyT int | string, TT any]
	TypeParams     string // [KeyT, TT]
	Options        []OptionMeta
}

func (OptionSpec) HasValidation added in v0.15.0

func (s OptionSpec) HasValidation() bool

type Options added in v0.47.0

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

func NewOptions added in v0.47.0

func NewOptions(
	options ...OptOptionsSetter,
) Options

func (*Options) Validate added in v0.47.0

func (o *Options) Validate() error

type TagOption

type TagOption struct {
	IsRequired    bool
	GoValidator   string
	Default       string
	Variadic      bool
	VariadicIsSet bool
	Skip          bool
}

Jump to

Keyboard shortcuts

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