Documentation
¶
Index ¶
- Variables
- func CutPrefix(prefix string) func(string) (string, bool)
- func HasPrefix(prefix string) func(string) bool
- func LoadMap(cfg *packages.Config, patterns ...string) (map[string]*Package, error)
- func TypeName(typ types.Type) string
- func TypePkg(typ types.Type) *types.Package
- type Comments
- func (c Comments) At(index int) string
- func (c Comments) Collect(fn func(line string) (string, bool)) (map[string]string, bool)
- func (c Comments) Filter(f func(line string) bool) Comments
- func (c Comments) Lookup(fn func(line string) (string, bool)) (string, bool)
- func (c Comments) LookupValue(prefix string) (string, bool)
- func (c Comments) String() string
- type FuncInfo
- type InterfaceInfo
- type Package
- func (pkg *Package) Comments(obj types.Object) Comments
- func (pkg *Package) CommentsAt(pos token.Pos) Comments
- func (pkg *Package) CommentsRaw(pos token.Pos) []*ast.CommentGroup
- func (pkg *Package) DefinedTypes() iter.Seq2[*types.Named, Comments]
- func (pkg *Package) Definitions() iter.Seq2[types.Object, Comments]
- func (pkg *Package) Funcs() iter.Seq2[FuncInfo, Comments]
- func (pkg *Package) Interfaces() iter.Seq2[InterfaceInfo, Comments]
- func (pkg *Package) NamedTypes() iter.Seq2[*types.Named, Comments]
- func (pkg *Package) Structs() iter.Seq2[StructInfo, Comments]
- type StructInfo
Constants ¶
This section is empty.
Variables ¶
var DefaultLoadMode = packages.LoadFiles | packages.LoadSyntax | packages.LoadImports
Functions ¶
Types ¶
type Comments ¶
type Comments []string
func (Comments) Collect ¶ added in v0.2.0
Collect call fn to convert comment into literal 'key1=value1 key2=value2', then collect the key and value pairs into map. Collect return true if any line converted by fn.
func (Comments) Lookup ¶ added in v0.1.0
Lookup execute fn on comment and return the 1st matched result.
func (Comments) LookupValue ¶ added in v0.1.0
LookupValue remove the prefix from 1st matched comment and return the remaining.
type Package ¶
type Package struct {
// package provider type information we need.
*packages.Package
// contains filtered or unexported fields
}
Package with doc associated.
func LoadPackage ¶
LoadPackage make sure pkg was loaded with correct LoadMode.
func (*Package) Comments ¶
Comments return comments in text slices, remove then '\n' in the end and nil values.
func (*Package) CommentsAt ¶
CommentsAt return comments at pos, remove line feed and nil comment group.
func (*Package) CommentsRaw ¶
func (pkg *Package) CommentsRaw(pos token.Pos) []*ast.CommentGroup
CommentsRaw return raw comment group, including nil.
func (*Package) Definitions ¶
Definitions return iterator over each object and its comments.
func (*Package) Funcs ¶
Funcs return iterator over each funcs (including abstract ones) and its comments.
func (*Package) Interfaces ¶
func (pkg *Package) Interfaces() iter.Seq2[InterfaceInfo, Comments]
Interfaces return iterator over each struct and its comments.
func (*Package) NamedTypes ¶ added in v0.4.1
NamedTypes return iterator over each defined type and its comments.