genlang

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package genlang provides parsing for godoc comment annotations

Index

Constants

View Source
const (
	ArgsRequired keywordFlag = 1 << iota // ArgsRequired requires a keyword to have an accompanying argument.
	NoArgs                               // NoArgs requires a keyword to be called without arguments.
	Exclusive                            // Exclusive limits the keyword to a single use per instance of field or struct.
)

If a flag's requirement is violated the scanner will return an error.

View Source
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 Arg added in v0.8.0

type Arg string

Arg is the raw string passed to a keyword that accepts an argument.

func (Arg) Count added in v0.8.0

func (a Arg) Count() int

Count returns the number of arguments separated by `\x00`

func (Arg) Seq added in v0.8.0

func (a Arg) Seq() iter.Seq[string]

Seq returns an iterator over the Arg separated by `\x00`

type ArgMap added in v0.8.0

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

ArgMap maps a singular key (string) to multiple values ([]Args), with convenience methods for accessing the values.

func (ArgMap) Get added in v0.8.0

func (m ArgMap) Get(s string) Arg

Get returns the argument for a given key.

func (ArgMap) Has added in v0.8.0

func (m ArgMap) Has(s string) bool

Has returns true if the MultiMap contains one or more Args instances for a given key.

func (ArgMap) Keys added in v0.8.0

func (m ArgMap) Keys() iter.Seq[string]

Keys returns an iterator over all of the keys in the MultiMap.

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 NamedTypeAnnotations added in v0.8.0

type NamedTypeAnnotations struct {
	Named ArgMap
}

NamedTypeAnnotations holds the MultiMap of keywords and arguments for a parser.NamedType

type Scanner

type Scanner interface {
	ScanStruct(*parser.Struct) (StructAnnotations, error)
	ScanNamedType(*parser.NamedType) (NamedTypeAnnotations, 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 StructAnnotations added in v0.8.0

type StructAnnotations struct {
	Struct ArgMap
	Fields []ArgMap
}

StructAnnotations holds the MultiMaps of keywords and arguments for a parser.Struct and each of its fields.

Jump to

Keyboard shortcuts

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