Documentation
¶
Index ¶
- Constants
- func GetFileNames(directory string) ([]string, error)
- type Annotation
- type AnnotationMode
- type AnnotationParser
- type ArrayAnnotationParser
- type Field
- type FileDesc
- type FileParser
- type ImportDesc
- type InterfaceDesc
- type InterfaceParser
- type MapAnnotationParser
- type MethodDesc
- type StructDesc
- type StructParser
Constants ¶
View Source
const AnnotationPrefix = "@"
Variables ¶
This section is empty.
Functions ¶
func GetFileNames ¶
Types ¶
type Annotation ¶
Annotation 注解
type AnnotationMode ¶
type AnnotationMode string // 注解模式
const ( AnnotationModeArray AnnotationMode = "array" // 数组注解模式 AnnotationModeMap AnnotationMode = "map" // map注解模式 )
type AnnotationParser ¶
type AnnotationParser interface {
Parse(comments []string) map[string]*Annotation
}
type ArrayAnnotationParser ¶
type ArrayAnnotationParser struct{}
func (*ArrayAnnotationParser) Parse ¶
func (a *ArrayAnnotationParser) Parse(comments []string) map[string]*Annotation
type Field ¶
type Field struct {
Name string // 字段名
DataType string // 字段类型
PackageName string // 包名
RealDataType string // 真实类型 不含指针
IsPtr bool // 是否是指针
}
Field 字段信息(入参、出参)
type FileDesc ¶
type FileDesc struct {
PackageName string // 包名
FullPackageName string // 完整包名
FileName string // 文件名
//RelativePath string // todo 相对路径
Imports map[string]*ImportDesc
Structs []*StructDesc
Interfaces []*InterfaceDesc
}
FileDesc 文件信息
func GetFileDesc ¶
func GetFileDesc(fileName string, mode AnnotationMode) (*FileDesc, error)
GetFileDesc 获取文件描述 fileName: 文件名
func GetFilesDescList ¶
func GetFilesDescList(directory string, mode AnnotationMode) ([]*FileDesc, error)
GetFilesDescList 获取文件描述列表 directory: 目录
type FileParser ¶
type FileParser struct {
// contains filtered or unexported fields
}
func GetFileParser ¶
func GetFileParser(filePath string) *FileParser
func (*FileParser) Parse ¶
func (f *FileParser) Parse() (*FileDesc, error)
type ImportDesc ¶
ImportDesc import信息
type InterfaceDesc ¶
type InterfaceDesc struct {
Name string // 接口名
Imports map[string]*ImportDesc // 导入信息
Comments []string // 注释
Annotations map[string]*Annotation // 注解
Methods []*MethodDesc // 方法
Description string // 描述
}
InterfaceDesc 接口信息
type InterfaceParser ¶
type InterfaceParser struct {
// contains filtered or unexported fields
}
func NewInterfaceParser ¶
func NewInterfaceParser( serviceName string, typeSpec *ast.TypeSpec, genDecl *ast.GenDecl, fileImports map[string]*ImportDesc) *InterfaceParser
func (*InterfaceParser) Parse ¶
func (s *InterfaceParser) Parse() (*InterfaceDesc, error)
type MapAnnotationParser ¶
type MapAnnotationParser struct{}
func (*MapAnnotationParser) Parse ¶
func (a *MapAnnotationParser) Parse(comments []string) map[string]*Annotation
type MethodDesc ¶
type MethodDesc struct {
Name string // 方法名
Description string // 描述
Comments []string // 注释
Annotations map[string]*Annotation // 注解
Params []*Field // 参数
Results []*Field // 返回值
}
MethodDesc 方法信息
type StructDesc ¶
type StructDesc struct {
Name string // 结构体名
Imports map[string]*ImportDesc // 导入信息
Comments []string // 注释
Annotations map[string]*Annotation // 注解
//Fields []*Field // 字段 暂不支持
Methods []*MethodDesc // 方法
Description string // 描述
}
StructDesc 结构体信息
type StructParser ¶
type StructParser struct {
// contains filtered or unexported fields
}
func NewStructParser ¶
func NewStructParser(serviceName string, typeSpec *ast.TypeSpec, genDecl *ast.GenDecl, file *ast.File, fileImports map[string]*ImportDesc) *StructParser
func (*StructParser) Parse ¶
func (s *StructParser) Parse() (*StructDesc, error)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.