Documentation ¶
Index ¶
- Constants
- Variables
- func CheckJsonImplements(ctx *DepthContext, node ast.Node) *ast.Ident
- func Convert(s string) string
- func DepthType(ctx *DepthContext) ast.Node
- func FindImportPath(importSpecs []*ast.ImportSpec, target string) string
- func FindPkgBySelector(pkg *packages.Package, file *ast.File, selector *ast.SelectorExpr) *packages.Package
- func FindStructByExpr(pkg *packages.Package, file *ast.File, expr ast.Expr) (*packages.Package, *ast.File, *ast.TypeSpec, *ast.StructType)
- func FindStructTypeByName(pkg *packages.Package, structName string) (*ast.File, *ast.TypeSpec, *ast.StructType)
- func FindTypeByName(pkg *packages.Package, TypeName string) (*ast.File, *ast.TypeSpec)
- func FormConvert(s string) string
- func GetFileNameByPos(fset *token.FileSet, pos token.Pos) string
- func IsSelector(field *ast.Field) (string, string, bool)
- func JudgeBuiltInType(t string) bool
- func LoadPackages(dir string) (string, *packages.Package, *token.FileSet)
- func MatchPathParam(s string) []string
- func NGTAG(s string) ngTag
- func Node2String(fset *token.FileSet, node interface{}) string
- func Node2SwagType(node ast.Node, selectName string) ast.Node
- func SelectorCover(expr *ast.SelectorExpr) *ast.Ident
- func SpliceType(pkg *packages.Package, file *ast.File, node ast.Node) bool
- func Struct2Ts(pkg *packages.Package, file *ast.File, node ast.Node, objName string) string
- func ToImportRawPath(importSpecs []*ast.ImportSpec) []string
- func ToTs(pkg *packages.Package, file *ast.File, node ast.Node, ...) []string
- func TrimImport(s string) string
- func WarpResult2Ts(pkg *packages.Package, file *ast.File, node ast.Node, objName string) string
- type ApiContext
- type Bind
- type DepthContext
- type ExtractStruct2Ts
- func (e *ExtractStruct2Ts) AddPendNodes(pkg *packages.Package, file *ast.File, node *ast.TypeSpec) bool
- func (e *ExtractStruct2Ts) MergePkg(pkg *packages.Package)
- func (e *ExtractStruct2Ts) Parse()
- func (e *ExtractStruct2Ts) Pend2Temp() bool
- func (e *ExtractStruct2Ts) SpliceType() bool
- func (e *ExtractStruct2Ts) SpliceTypeV2() bool
- func (e *ExtractStruct2Ts) Temp2ResolveNodes()
- func (e *ExtractStruct2Ts) ToTs(format func(string) string) []string
- type FileContext
- func (c *FileContext) ApiMark2SwagRouter(fields []string) (Router, string)
- func (c *FileContext) FilterFunc() []*ast.FuncDecl
- func (c *FileContext) Func2Ts()
- func (c *FileContext) GinFormat(f *ast.FuncDecl) bool
- func (c *FileContext) HasApiMark(doc *ast.CommentGroup) bool
- func (c *FileContext) Parse(option ParseOption)
- func (c *FileContext) ParseBind(inPkg *packages.Package, inFile *ast.File, funcName string, ...) Bind
- func (c *FileContext) ParseComment(fc *Func, ms []*ast.Comment, inField *ast.Field, outField *ast.Field)
- func (c *FileContext) ParseFunc(f *ast.FuncDecl) Func
- func (c *FileContext) Struct2Quote(fset *token.FileSet, field *ast.Field) string
- type Func
- type ImportMsg
- type NodeInfo
- type ParseOption
- type Plugins
- type QuoteType
- type Router
- type Set
- type Seter
- type TagMsg
- func FindTagAndCommentByField(pkg *packages.Package, file *ast.File, field *ast.Field, TagName string) []TagMsg
- func FindTagAndCommentByStruct(pkg *packages.Package, file *ast.File, structType *ast.StructType, ...) []TagMsg
- func FindTagByType(pkg *packages.Package, file *ast.File, ty ast.Node, tagName string) []TagMsg
Constants ¶
View Source
const CasbinMark string = "@Casbin"
View Source
const GenMark string = "@GenApi"
View Source
const NGForm = "ngform"
Variables ¶
View Source
var Indent = " "
View Source
var JsonInterface *types.Interface
Functions ¶
func CheckJsonImplements ¶
func CheckJsonImplements(ctx *DepthContext, node ast.Node) *ast.Ident
func DepthType ¶
func DepthType(ctx *DepthContext) ast.Node
func FindImportPath ¶
func FindImportPath(importSpecs []*ast.ImportSpec, target string) string
func FindPkgBySelector ¶
func FindStructByExpr ¶
func FindStructTypeByName ¶
func FindTypeByName ¶
func FormConvert ¶
func MatchPathParam ¶
func Node2String ¶
func Node2SwagType ¶
type Req struct { 转换部分 xxx.Client Name Client }
func SelectorCover ¶
func SelectorCover(expr *ast.SelectorExpr) *ast.Ident
func ToImportRawPath ¶
func ToImportRawPath(importSpecs []*ast.ImportSpec) []string
print "fmt.print"
func TrimImport ¶
Types ¶
type ApiContext ¶
type ApiContext struct { PkgName string Fset *token.FileSet Pkg *packages.Package Files map[string]*FileContext ReginsterMap map[string][]Func }
func NewApiContext ¶
func NewApiContext() *ApiContext
func (*ApiContext) FuncsToMapByRouterGroupKey ¶
func (c *ApiContext) FuncsToMapByRouterGroupKey()
func (*ApiContext) Load ¶
func (c *ApiContext) Load(dir string)
func (*ApiContext) Parse ¶
func (c *ApiContext) Parse(option ParseOption)
type Bind ¶
type Bind struct { Uri struct { Has bool Param []string TagMsgs []TagMsg } Body struct { Has bool QuoteType QuoteType Comment string SwagStructName string SwagRaw string SwagObj string } Query struct { Has bool QuoteType QuoteType Comment string SwagStructName string SwagRaw string SwagObj string } Header struct { Has bool TagMsgs []TagMsg } CtxKey struct { Has bool } }
type DepthContext ¶
func NewDepthContext ¶
type ExtractStruct2Ts ¶
type ExtractStruct2Ts struct { PendNodeRecord map[string]struct{} PendNodes []NodeInfo ResolveNodes []NodeInfo ResolveMergePkg map[string]struct{} TempNodeInfo NodeInfo EnterType NodeInfo }
func NewExtractStruct2Ts ¶
func (*ExtractStruct2Ts) AddPendNodes ¶
func (*ExtractStruct2Ts) MergePkg ¶
func (e *ExtractStruct2Ts) MergePkg(pkg *packages.Package)
func (*ExtractStruct2Ts) Parse ¶
func (e *ExtractStruct2Ts) Parse()
func (*ExtractStruct2Ts) Pend2Temp ¶
func (e *ExtractStruct2Ts) Pend2Temp() bool
func (*ExtractStruct2Ts) SpliceType ¶
func (e *ExtractStruct2Ts) SpliceType() bool
func (*ExtractStruct2Ts) SpliceTypeV2 ¶
func (e *ExtractStruct2Ts) SpliceTypeV2() bool
func (*ExtractStruct2Ts) Temp2ResolveNodes ¶
func (e *ExtractStruct2Ts) Temp2ResolveNodes()
type FileContext ¶
type FileContext struct { PkgName string Pkg *packages.Package File *ast.File CasbinInterfaceType1 *types.Interface CasbinInterfaceType2 *types.Interface //ImportMsgs map[string]ImportMsg Funcs []Func }
func NewFileContext ¶
func (*FileContext) ApiMark2SwagRouter ¶
func (c *FileContext) ApiMark2SwagRouter(fields []string) (Router, string)
func (*FileContext) FilterFunc ¶
func (c *FileContext) FilterFunc() []*ast.FuncDecl
func (*FileContext) Func2Ts ¶
func (c *FileContext) Func2Ts()
func (*FileContext) GinFormat ¶
func (c *FileContext) GinFormat(f *ast.FuncDecl) bool
GinFormat 符合 func Name(c *gin.context, in object) (out object, err error)
func (*FileContext) HasApiMark ¶
func (c *FileContext) HasApiMark(doc *ast.CommentGroup) bool
HasApiMark 注释包含@GenApi的才符合规范
func (*FileContext) Parse ¶
func (c *FileContext) Parse(option ParseOption)
func (*FileContext) ParseBind ¶
func (c *FileContext) ParseBind(inPkg *packages.Package, inFile *ast.File, funcName string, structType *ast.StructType) Bind
func (*FileContext) ParseComment ¶
func (*FileContext) Struct2Quote ¶
type ParseOption ¶
type ParseOption struct {
ParseTs bool
}
type Plugins ¶
type Plugins struct { Point []plugins.PointTemplate CallBack plugins.CallBackTemplate }
type QuoteType ¶
type QuoteType string
const IdentType QuoteType = "ident"
const StructType QuoteType = "struct"
Source Files ¶
Click to show internal directories.
Click to hide internal directories.