Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Const ¶ added in v0.2.0
type Const struct { Doc string `json:"doc,omitempty"` Names []string `json:"names"` Values []Value `json:"values"` // contains filtered or unexported fields }
Const represents a single const declaration.
func (Const) IsExported ¶ added in v0.2.0
IsExported returns true if the first name is exported.
func (Const) Print ¶ added in v0.2.0
Print writes the unformatted const declaration code fragment to writer.
func (Const) String ¶ added in v0.2.0
String returns the unformatted const declaration code fragment.
func (Const) SymbolType ¶ added in v0.2.0
func (Const) SymbolType() SymbolType
SymbolType returns SymbolConst.
type ConstGroup ¶ added in v0.2.0
ConstGroup represents one or more const declarations.
func (ConstGroup) Print ¶ added in v0.2.0
func (cg ConstGroup) Print(w io.Writer)
Print writes unformatted const declaration code to writer.
func (ConstGroup) String ¶ added in v0.2.0
func (cg ConstGroup) String() string
String returns the unformatted const declaration code.
type Field ¶ added in v0.1.1
type Field struct { Type string `json:"type"` Doc string `json:"doc,omitempty"` Comment string `json:"comment,omitempty"` Names []string `json:"names,omitempty"` Tags []FieldTag `json:"tags,omitempty"` // contains filtered or unexported fields }
Field represents a function parameter, result, or struct field.
func (Field) IsExported ¶ added in v0.1.1
IsExported returns true if the field is exported.
func (Field) SymbolType ¶ added in v0.2.0
func (sf Field) SymbolType() SymbolType
SymbolType returns either SymbolStructField, SymbolParamField, or SymbolResultField.
type FieldTag ¶ added in v0.3.0
FieldTag represents a struct field tag.
type FilterAction ¶ added in v0.2.0
type FilterAction int
FilterAction configures a [SymbolFilterFn].
const ( Exclude FilterAction = iota // Exclude symbols. Include // Include symbols. )
func (FilterAction) GoString ¶ added in v0.2.0
func (fa FilterAction) GoString() string
func (FilterAction) String ¶ added in v0.2.0
func (fa FilterAction) String() string
String returns a string representation of a filter action.
type Func ¶
type Func struct { Receiver *Field `json:"receiver,omitempty"` Name string `json:"name"` Doc string `json:"doc,omitempty"` Comment string `json:"comment,omitempty"` Params []Field `json:"params,omitempty"` Results []Field `json:"results,omitempty"` // contains filtered or unexported fields }
Func represents a function or a struct method if the Receiver field contains a pointer to a [FuncReceiver].
func (Func) IsExported ¶
IsExported returns true if the function is exported.
func (Func) SymbolType ¶ added in v0.2.0
func (f Func) SymbolType() SymbolType
SymbolType returns SymbolFunc or SymbolMethod.
type Package ¶
type Package struct { Name string `json:"name"` Doc string `json:"doc,omitempty"` Consts []ConstGroup `json:"consts,omitempty"` Funcs []Func `json:"funcs,omitempty"` Types []TypeDef `json:"types,omitempty"` }
Package represents a go package containing functions and types such as structs and interfaces.
func (*Package) IsExported ¶ added in v0.2.0
IsExported always returns true for packages.
func (*Package) SymbolType ¶ added in v0.2.0
func (*Package) SymbolType() SymbolType
SymbolType returns SymbolPackage.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser parses go packages to simple structs.
func NewParser ¶
func NewParser(opts ...ParserOption) (*Parser, error)
NewParser returns a parser configured with options.
type ParserOption ¶ added in v0.2.0
type ParserOption interface { // String should return a string representation of the option. // // This method is mainly intended for testing purposes. String() string // contains filtered or unexported methods }
ParserOption configures a Parser.
func WithFullDocs ¶ added in v0.2.0
func WithFullDocs() ParserOption
WithFullDocs configures a Parser to include full doc comments instead of short synopsis comments.
func WithNoDocs ¶ added in v0.2.0
func WithNoDocs() ParserOption
WithNoDocs configures a Parser to not include any doc comments for symbols.
func WithNoTags ¶ added in v0.3.0
func WithNoTags() ParserOption
WithNoDocs configures a Parser to not include any struct field tags.
func WithSymbolFilters ¶ added in v0.2.0
func WithSymbolFilters(filters ...SymbolFilter) ParserOption
WithSymbolFilters configures a Parser to filter package symbols with provided filter functions.
type Symbol ¶ added in v0.2.0
type Symbol interface { Ident() string IsExported() bool SymbolType() SymbolType }
Symbol represents a symbol such as a const, type definition, or function.
type SymbolFilter ¶ added in v0.2.0
type SymbolFilter interface { // Include should return true if symbol should be included according to // the filter's logic and configuration. Include(Symbol) bool // String should return a string representation of the filter. // // This method is mainly intended for testing purposes. String() string }
SymbolFilter filters symbols by different conditions.
func FilterMatchingIdents ¶ added in v0.2.0
func FilterMatchingIdents(action FilterAction, p *regexp.Regexp) SymbolFilter
FilterSymbolTypes creates a filter function that determines whether to include or exclude symbols with matching idents.
func FilterSymbolTypes ¶ added in v0.2.0
func FilterSymbolTypes(action FilterAction, types ...SymbolType) SymbolFilter
FilterSymbolTypes creates a filter function that determines whether to include or exclude symbols of different types.
func FilterUnexported ¶ added in v0.2.0
func FilterUnexported(action FilterAction) SymbolFilter
FilterUnexported creates a filter that determines whether to include or exclude unexported symbols.
type SymbolType ¶ added in v0.2.0
type SymbolType int
SymbolType represents a type of package symbol.
const ( SymbolUnknown SymbolType = iota SymbolPackage // `package mypackage` SymbolConst // `const myConst = ...` SymbolIdentType // `type MyInt int` SymbolFuncType // `type MyFunc func(...)` SymbolStructType // `type MyStruct { ... }` SymbolInterfaceType // `type MyInterface { ... }` SymbolMapType // `type MyMap map[...]...` SymbolChanType // `type MyChan chan ...` SymbolArrayType // `type MyArray []string` SymbolFunc // `func MyFunc(...) { ... }` SymbolMethod // `func (...) MyMethod(...) { ... }` SymbolStructField // Struct field. SymbolParamField // Function parameter field. SymbolResultField // Function result field. SymbolReceiverField // Function Receiver field. )
func (SymbolType) GoString ¶ added in v0.2.0
func (st SymbolType) GoString() string
func (SymbolType) String ¶ added in v0.2.0
func (st SymbolType) String() string
String returns a string representation of a symbol type.
type TypeDef ¶ added in v0.1.1
type TypeDef struct { Type string `json:"type"` Name string `json:"name"` Doc string `json:"doc,omitempty"` Key string `json:"key,omitempty"` Value string `json:"value,omitempty"` Dir string `json:"dir,omitempty"` Elt string `json:"elt,omitempty"` Len string `json:"len,omitempty"` Params []Field `json:"params,omitempty"` Results []Field `json:"results,omitempty"` Fields []Field `json:"fields,omitempty"` Methods []Func `json:"methods,omitempty"` }
TypeDef represents a type definition.
func (TypeDef) IsExported ¶ added in v0.1.1
IsExported returns true if the type definition is exported.
func (TypeDef) SymbolType ¶ added in v0.2.0
func (td TypeDef) SymbolType() SymbolType
SymbolType returns the type definition's symbol type.