Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExampleDeprecationNote
deprecated
added in
v1.1.0
func ExampleDeprecationNote()
ExampleDeprecationNote is an example of a deprecated function
Deprecated: This function is deprecated only for demonstration purposes
func GetPackages ¶
GetPackages returns a list of all package directories in the project
Example:
packages, err := parser.GetPackages() if err != nil { log.Fatalf("Error fetching packages: %v", err) } for _, pkg := range packages { fmt.Printf("Package: %s\n", pkg) }
Types ¶
type DescriptionData ¶ added in v1.1.0
type DescriptionData struct { Description string Example string Notes string DeprecationNote string // Raw fields DescriptionRaw string DeprecationNoteRaw string }
DescriptionData contains different parts of a function's documentation comment
type EntityExtractor ¶ added in v1.1.0
type EntityExtractor interface {
Extract(decl ast.Decl, fs *token.FileSet, interfaces map[string]EntityInfo, pkgName string) EntityInfo
}
EntityExtractor defines an interface for extracting information from AST declarations
type EntityInfo ¶
type EntityInfo struct { Name string Description string Example string Notes string DeprecationNote string Parameters []string Returns []string Body string Type string Fields []FieldInfo Methods []MethodInfo Implements []ImplementationInfo Package string // Raw fields DescriptionRaw string DeprecationNoteRaw string }
EntityInfo contains relevant information about each entity in the package (functions, types, interfaces)
func ParseEntitiesInPackage ¶
func ParseEntitiesInPackage(pkgPath string) ([]EntityInfo, error)
ParseEntitiesInPackage parses the entities in a given package and returns a slice of EntityInfo
Example:
entities, err := parser.ParseEntitiesInPackage("github.com/gophercises/quiz") if err != nil { log.Fatalf("Error parsing entities: %v", err) } for _, entity := range entities { fmt.Printf("Name: %s\n", entity.Name) fmt.Printf("Type: %s\n", entity.Type) fmt.Printf("Description: %s\n", entity.Description) fmt.Printf("Package: %s\n", entity.Package) }
Notes: The package must be a full path to the package directory
type FieldInfo ¶ added in v1.1.0
FieldInfo contains relevant information about each field in a struct
type FunctionExtractor ¶ added in v1.1.0
type FunctionExtractor struct{}
FunctionExtractor extracts information from function declarations
func (FunctionExtractor) Extract ¶ added in v1.1.0
func (f FunctionExtractor) Extract(decl ast.Decl, fs *token.FileSet, interfaces map[string]EntityInfo, pkgName string) EntityInfo
type ImplementationInfo ¶ added in v1.1.0
ImplementationInfo contains information about an implemented interface
type InterfaceExtractor ¶ added in v1.1.0
type InterfaceExtractor struct{}
InterfaceExtractor extracts information from interface declarations
func (InterfaceExtractor) Extract ¶ added in v1.1.0
func (i InterfaceExtractor) Extract(decl ast.Decl, fs *token.FileSet, interfaces map[string]EntityInfo, pkgName string) EntityInfo
type MethodInfo ¶ added in v1.1.0
MethodInfo contains relevant information about each method in an interface
type StructExtractor ¶ added in v1.1.0
type StructExtractor struct{}
StructExtractor extracts information from struct declarations
func (StructExtractor) Extract ¶ added in v1.1.0
func (s StructExtractor) Extract(decl ast.Decl, fs *token.FileSet, interfaces map[string]EntityInfo, pkgName string) EntityInfo
type TypeExtractor ¶ added in v1.1.0
type TypeExtractor struct{}
TypeExtractor extracts information from type declarations
func (TypeExtractor) Extract ¶ added in v1.1.0
func (t TypeExtractor) Extract(decl ast.Decl, fs *token.FileSet, interfaces map[string]EntityInfo, pkgName string) EntityInfo