Documentation
¶
Overview ¶
Package genlang provides parsing for godoc comment annotations
Index ¶
- Constants
- type Args
- type KeywordOpts
- type MultiMap
- func (m MultiMap) Get(s string) []Args
- func (m MultiMap) GetDualArgs(s string) iter.Seq2[string, *string]
- func (m MultiMap) GetOne(s string) Args
- func (m MultiMap) GetSingleArgs(s string) iter.Seq[string]
- func (m MultiMap) Has(s string) bool
- func (m MultiMap) Iter(s string) iter.Seq[Args]
- func (m MultiMap) Keys() iter.Seq[string]
- type NamedTypeResults
- type Scanner
- type StructResults
Constants ¶
const ( // ArgsRequired requires a keyword to have an accompanying argument. ArgsRequired keywordFlag = 1 << iota // DualArgsRequired requires a keyword to have two comma-separated arguments. DualArgsRequired // NoArgs requires a keyword to be called without arguments. NoArgs // StrictSingleArgs limits the number of comma-separated arguments to one StrictSingleArgs // Exclusive limits the keyword to a single use per instance of field or struct. Exclusive )
If a flag's requirement is violated the scanner will return an error.
const ( ScanStruct scanMode = iota ScanField ScanNamedType )
Scanning modes configure the scanner for different generation/parser types.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Args ¶
Args contains the raw string data for an argument, and possibly a second argument separated by a comma.
type KeywordOpts ¶
type KeywordOpts map[scanMode]keywordFlag
KeywordOpts is used to configure the flags for keywords based on the scan mode (field or struct).
type MultiMap ¶
type MultiMap struct {
// contains filtered or unexported fields
}
MultiMap maps a singular key (string) to multiple values ([]Args), with convenience methods for accessing the values.
func (MultiMap) GetDualArgs ¶
GetDualArgs returns an iterator over the first and second argument in each instance of Args for a given key.
func (MultiMap) GetOne ¶
GetOne returns the first instance of Args for a given key. The caller should check that Args *do* exist for the given key before calling.
func (MultiMap) GetSingleArgs ¶
GetSingleArgs returns an iterator over the first argument in each instance of Args for a given key.
func (MultiMap) Has ¶
Has returns true if the MultiMap contains one or more Args instances for a given key.
type NamedTypeResults ¶ added in v0.2.3
type NamedTypeResults struct {
Named MultiMap
}
NamedTypeResults holds the MultiMap of keywords and arguments for a parser.NamedType
type Scanner ¶
type Scanner interface {
ScanStruct(*parser.Struct) (StructResults, error)
ScanNamedType(*parser.NamedType) (NamedTypeResults, error)
}
Scanner provides methods for parsing godoc annotations on various types from the generation/parser package.
func NewScanner ¶
func NewScanner(keywords map[string]KeywordOpts) Scanner
NewScanner constructs a Scanner with the given keywords and keyword options.
type StructResults ¶ added in v0.2.3
StructResults holds the MultiMaps of keywords and arguments for a parser.Struct and each of its fields.