Documentation ¶
Overview ¶
Package options parses function comments and sets them to fields.
Index ¶
- Constants
- func FilterDepth(field *models.Field, maxdepth, curdepth int) []*models.Field
- func IsMatchOptionCategory(c string) bool
- func IsMatchOptionSet(field models.Field) bool
- func MapCustomOption(optionmap map[string][]string, option *Option) (map[string][]string, error)
- func MapCustomOptions(options []*Option) (map[string][]string, error)
- func SetAutomatch(field *models.Field, option Option)
- func SetConvert(field *models.Field, option Option)
- func SetDeepcopy(field *models.Field, option Option)
- func SetDepth(field *models.Field, option Option)
- func SetFieldOptions(field *models.Field, fieldoptions []*Option)
- func SetMap(field *models.Field, option Option)
- func SetTag(field *models.Field, option Option)
- type Option
- func NewFieldOption(category, text string) (*Option, error)
- func ParseAutomatch(option string) (*Option, error)
- func ParseConvert(option, value string) (*Option, error)
- func ParseDeepcopy(option string) (*Option, error)
- func ParseDepth(option string) (*Option, error)
- func ParseMap(option string) (*Option, error)
- func ParseTag(option string) (*Option, error)
Constants ¶
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>" )
const ( CategoryCustom = "custom" FormatCustom = "<option><whitespaces><value>" )
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>" )
const ( CategoryAutomatch = "automatch" // FormatAutomatch represents an end-user facing format for automatch options. // <option> refers to the "automatch" option. FormatAutomatch = "<option>:<whitespaces><regex>" )
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>" )
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>" )
const CategoryDeepcopy = "deepcopy"
Variables ¶
This section is empty.
Functions ¶
func FilterDepth ¶ added in v0.3.3
FilterDepth filters a field according to it's depth level and returns the removed fields.
func IsMatchOptionCategory ¶
IsMatchOptionCategory determines if a given string is a match option category.
func IsMatchOptionSet ¶
IsMatchOptionSet determines if a match option is already set for a given field.
func MapCustomOption ¶
MapCustomOption maps a custom option in an optionmap[category][]values.
func MapCustomOptions ¶
MapCustomOptions maps options with custom categories in a list of options to a customoptionmap[category][]value.
func SetAutomatch ¶
SetAutomatch sets a field's automatch option.
func SetConvert ¶
SetConvert sets a field's convert option.
func SetDeepcopy ¶
SetDeepcopy sets a field's deepcopy option.
func SetFieldOptions ¶
SetFieldOptions sets a field's (and its subfields) options.
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 ¶
NewFieldOption creates a new field-oriented option from the given category and text.
func ParseAutomatch ¶
ParseAutomatch parses a automatch option.
func ParseConvert ¶
ParseConvert parses a convert option.
func ParseDeepcopy ¶
ParseDeepcopy parses a deepcopy option.