Documentation ¶
Index ¶
- Constants
- func CheckGoScanPath(pkg string, enableGoMod bool) error
- func CreateDefaultConfig() error
- func FindGOModAbsPath(root string) string
- func GetDocScanners() map[string]DocScanner
- func GetFileImportsAtFile(fileName string, mod *GoModuleInfo) (map[string]string, error)
- func GetFileImportsAtNode(node ast.Node, pkg *ast.Package, fileset *token.FileSet, mod *GoModuleInfo) map[string]string
- func GetGOPaths() []string
- func GetGOSrcPaths() []string
- func GetGenerators() map[string]DocGenerator
- func GetObjectLoaders() map[string]ObjectLoader
- func GetScanDirs(pkg string, mod bool, filter func(dirName string) bool) []string
- func GetSubDirs(root string) []string
- func ModulePath(mod []byte) string
- func ParseDir(dir string) (map[string]*ast.Package, *token.FileSet, error)
- func RandObjectID(s string) string
- func RegisterDocScanner(scanner DocScanner)
- func RegisterGenerator(generator DocGenerator)
- func RegisterObjectLoader(loader ObjectLoader)
- type API
- type Config
- type DocGenContext
- type DocGenerator
- type DocScanConfig
- type DocScanResult
- type DocScanner
- type Extension
- type ExtensionGoTag
- type ExtensionUnknown
- type GeneratedFile
- type GeneratedOutput
- type GoModuleInfo
- type Inject
- type LangObjectId
- type MimeType
- type Object
- type ObjectField
- type ObjectFieldTag
- type ObjectLoader
- type ObjectLoaderConfig
- type ObjectType
- type Project
- func (project *Project) AddLangObject(id LangObjectId, value *Object)
- func (project *Project) GetLangObject(id LangObjectId) *Object
- func (project *Project) LoadObjects(schemaDef *schema.Schema) error
- func (project *Project) Objects() map[LangObjectId]*Object
- func (project *Project) ParseSchemaAPI(api *schema.API) (*API, error)
- type TypeScope
Constants ¶
const (
Version = "0.8"
)
Variables ¶
This section is empty.
Functions ¶
func CheckGoScanPath ¶
func CreateDefaultConfig ¶
func CreateDefaultConfig() error
func FindGOModAbsPath ¶
FindGOModAbsPath find the first(in dep) absolute path which contains go.mod file
func GetDocScanners ¶
func GetDocScanners() map[string]DocScanner
GetScanners get all registered scanners
func GetFileImportsAtFile ¶
func GetFileImportsAtFile(fileName string, mod *GoModuleInfo) (map[string]string, error)
func GetFileImportsAtNode ¶
func GetFileImportsAtNode(node ast.Node, pkg *ast.Package, fileset *token.FileSet, mod *GoModuleInfo) map[string]string
GetFileImportsAtNode infer filename from node and then get the file imports
func GetGenerators ¶
func GetGenerators() map[string]DocGenerator
GetGenerators get all registered generator
func GetObjectLoaders ¶
func GetObjectLoaders() map[string]ObjectLoader
GetObjectLoaders get all registered object loaders
func GetScanDirs ¶
GetScanDirs get the dirs to scan
func GetSubDirs ¶
func ModulePath ¶
ModulePath returns the module path from the gomod file text. If it cannot find a module path, it returns an empty string. It is tolerant of unrelated problems in the go.mod file. Copy from go sdk 1.12.7
func RandObjectID ¶
func RegisterDocScanner ¶
func RegisterDocScanner(scanner DocScanner)
RegisterDocScanner to global doc scanners
func RegisterGenerator ¶
func RegisterGenerator(generator DocGenerator)
RegisterGenerator to global generator
func RegisterObjectLoader ¶
func RegisterObjectLoader(loader ObjectLoader)
RegisterObjectLoader to global object loader
Types ¶
type API ¶
type API struct { schema.API InArgument *Object `json:"in_argument"` OutArgument *Object `json:"out_argument"` Mime *MimeType }
API def
type Config ¶
type Config struct { Name string `yaml:"name"` Description string `yaml:"desc"` APIBaseURL string `yaml:"api_base_url"` // https://api.xxx.com Injects []*Inject `yaml:"inject"` // Scanner []string `yaml:"scanner"` Generator []string `yaml:"generator"` Mime *MimeType `yaml:"mime"` // MimeType Args map[string]string `yaml:"args"` // contains filtered or unexported fields }
func LoadDefaultConfig ¶
type DocGenContext ¶
type DocGenerator ¶
type DocGenerator interface { // Generate doc Gen(ctx *DocGenContext) (output *GeneratedOutput, err error) // Generator Name Name() string }
DocGenerator receive a DocGenContext output a doc
type DocScanConfig ¶
type DocScanner ¶
type DocScanner interface { Scan(config DocScanConfig) (*DocScanResult, error) Name() string Help() string }
type ExtensionGoTag ¶
type ExtensionGoTag struct {
Tag *ObjectFieldTag
}
func (*ExtensionGoTag) Name ¶
func (e *ExtensionGoTag) Name() string
type ExtensionUnknown ¶
type ExtensionUnknown struct { OriginExtensionName string OriginData json.RawMessage }
func (*ExtensionUnknown) Name ¶
func (e *ExtensionUnknown) Name() string
type GeneratedFile ¶
type GeneratedOutput ¶
type GeneratedOutput struct {
Files []*GeneratedFile
}
type GoModuleInfo ¶
type LangObjectId ¶
type Object ¶
type Object struct { ID string Type *ObjectType Fields []*ObjectField Extensions []Extension Loaded bool }
Object info
func CreateArrayObject ¶
Create a n-dimensional(dep) array object
func CreateArrayObjectByID ¶
Create and register a n-dimensional(dep) array object by leaf object id
func CreateRootObject ¶
CreateRootObject create root object by package and type returns the created obj(return Object[0]) an refs object
type ObjectField ¶
type ObjectField struct { Name string Desc string Type *ObjectType Extensions []Extension }
ObjectField filed info
type ObjectFieldTag ¶
type ObjectFieldTag struct {
// contains filtered or unexported fields
}
func NewObjectFieldTag ¶
func NewObjectFieldTag(raw string) (*ObjectFieldTag, error)
func (*ObjectFieldTag) GetFirstValue ¶
func (o *ObjectFieldTag) GetFirstValue(tagName string, sep string) string
func (*ObjectFieldTag) GetValue ¶
func (o *ObjectFieldTag) GetValue(tagName string) string
type ObjectLoader ¶
type ObjectLoader interface { Load(ts TypeScope) (*Object, error) LoadAll(tss []TypeScope) ([]*Object, error) Add(object *Object) error GetObjectId(ts TypeScope) (string, error) SetConfig(cfg *ObjectLoaderConfig) Lang() string }
func GetObjectLoader ¶
func GetObjectLoader(lang string) ObjectLoader
GetObjectLoader get one registered object loader
type ObjectLoaderConfig ¶
type ObjectLoaderConfig struct {
Config
}
type ObjectType ¶
ObjectType describe a object
Name is one of below: object, string, bool, byte, interface{}, int,int8,int16,int32,int64, uint,uint8,uint16,uint32,uint64, float,float32,float64
Ref describe which object to reference ¶
IsRepeated will be true if that is a array/slice type
type Project ¶
type Project struct { Config *Config Scanners []DocScanner `yaml:"-"` Generators []DocGenerator `yaml:"-"` // contains filtered or unexported fields }
func NewProject ¶
func (*Project) AddLangObject ¶
func (project *Project) AddLangObject(id LangObjectId, value *Object)
func (*Project) GetLangObject ¶
func (project *Project) GetLangObject(id LangObjectId) *Object
func (*Project) Objects ¶
func (project *Project) Objects() map[LangObjectId]*Object