options

package
v0.0.0-...-429302c Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package options parses function comments and sets them to fields.

Index

Constants

View Source
const (
	CategoryConvert = "convert"

	// FormatConvert represents an end-user facing format for convert options.
	// <option> refers to the "convert" option.
	FormatConvert = "<option>:<whitespaces><regex><whitespaces><regex>"
)
View Source
const (
	CategoryCustom = "custom"
	FormatCustom   = "<option><whitespaces><value>"
)
View Source
const (
	CategoryDepth = "depth"

	// FormatDepth represents an end-user facing format for depth options.
	// <option> refers to the "depth" option.
	FormatDepth = "<option>:<whitespaces><regex><whitespaces><int>"
)
View Source
const (
	CategoryAutomatch = "automatch"

	// FormatAutomatch represents an end-user facing format for automatch options.
	// <option> refers to the "automatch" option.
	FormatAutomatch = "<option>:<whitespaces><regex>"
)
View Source
const (
	CategoryMap = "map"

	// FormatMap represents an end-user facing format for map options.
	// <option> refers to the "map" option.
	FormatMap = "<option>:<whitespaces><regex><whitespaces><field>"
)
View Source
const (
	CategoryTag = "tag"

	// FormatTag represents an end-user facing format for tag options.
	// <option> refers to the "tag" option.
	FormatTag = "<option>:<whitespaces><regex><whitespaces><tag>"
)
View Source
const (
	CategoryNoCase = "nocase"

	// FormatNoCase represents an end-user facing format for nocase options.
	// <option> refers to the "nocase" option.
	FormatNoCase = "<option>"
)
View Source
const (
	CategoryPostProcess = "postprocess"

	// FormatPostProcess represents an end-user facing format for postProcess options.
	// <option> refers to the "postprocess" option.
	FormatPostProcess = "<option>:<whitespaces><ident>"
)
View Source
const (
	CategoryPreProcess = "preprocess"

	// FormatPreProcess represents an end-user facing format for preProcess options.
	// <option> refers to the "preprocess" option.
	FormatPreProcess = "<option>:<whitespaces><ident>"
)
View Source
const CategoryDeepcopy = "deepcopy"

Variables

This section is empty.

Functions

func FilterDepth

func FilterDepth(field *models.Field, maxdepth, curdepth int) []*models.Field

FilterDepth filters a field according to it's depth level and returns the removed fields.

func IsMatchOptionCategory

func IsMatchOptionCategory(c string) bool

IsMatchOptionCategory determines if a given string is a match option category.

func IsMatchOptionSet

func IsMatchOptionSet(field models.Field) bool

IsMatchOptionSet determines if a match option is already set for a given field.

func MapCustomOption

func MapCustomOption(optionmap map[string][]string, option *Option) (map[string][]string, error)

MapCustomOption maps a custom option in an optionmap[category][]values.

func MapCustomOptions

func MapCustomOptions(options []*Option) (map[string][]string, error)

MapCustomOptions maps options with custom categories in a list of options to a customoptionmap[category][]value.

func SetAutomatch

func SetAutomatch(field *models.Field, option Option)

SetAutomatch sets a field's automatch option.

func SetConvert

func SetConvert(field *models.Field, option Option)

SetConvert sets a field's convert option.

func SetDeepcopy

func SetDeepcopy(field *models.Field, option Option)

SetDeepcopy sets a field's deepcopy option.

func SetDepth

func SetDepth(field *models.Field, option Option)

SetDepth sets a field's depth option.

func SetFieldOptions

func SetFieldOptions(field *models.Field, fieldoptions []*Option)

SetFieldOptions sets a field's (and its subfields) options.

func SetMap

func SetMap(field *models.Field, option Option)

SetMap sets a field's map option.

func SetTag

func SetTag(field *models.Field, option Option)

SetTag sets a field's tag option.

Types

type Option

type Option struct {
	// The compiled regex the option uses for its arguments (map[position]regex).
	Regex map[int]*regexp.Regexp

	// The values to assign to a type (function or field) if the option applies.
	Value interface{}

	// The category the option falls under.
	Category string
}

Option represents an option applied to functions and fields.

func NewFieldOption

func NewFieldOption(category, text string) (*Option, error)

NewFieldOption creates a new field-oriented option from the given category and text.

func ParseAutomatch

func ParseAutomatch(option string) (*Option, error)

ParseAutomatch parses a automatch option.

func ParseConvert

func ParseConvert(option, value string, funcType *ast.FuncType) (*Option, error)

ParseConvert parses a convert option.

func ParseDeepcopy

func ParseDeepcopy(option string) (*Option, error)

ParseDeepcopy parses a deepcopy option.

func ParseDepth

func ParseDepth(option string) (*Option, error)

ParseDepth parses a depth option.

func ParseMap

func ParseMap(option string) (*Option, error)

ParseMap parses a map option.

func ParseNoCase

func ParseNoCase(option string) (*Option, error)

ParseNoCase parses a noCase option.

func ParsePostProcess

func ParsePostProcess(option string) (*Option, error)

ParsePostProcess parses a postprocess option.

func ParsePreProcess

func ParsePreProcess(option string) (*Option, error)

ParsePreProcess parses a preprocess option.

func ParseTag

func ParseTag(option string) (*Option, error)

ParseTag parses a tag option.

Jump to

Keyboard shortcuts

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