Documentation ¶
Index ¶
- Constants
- Variables
- func CreateFileFromTemplate(fileName string, template *template.Template, data interface{})
- func CreatePool(program *loader.Program, dir string)
- func GetModelsASTData(program *loader.Program) map[string]ModelASTData
- func GetModelsASTDataForModules(modInfos []*ModuleInfo) map[string]ModelASTData
- func GetModulePaths(program *loader.Program) []string
- type FieldASTData
- type MethodASTData
- type ModelASTData
- type ModuleInfo
- type PackageType
- type ParamData
- type TypeData
Constants ¶
const ( // YEPPath is the go import path of the base yep package YEPPath string = "github.com/npiganeau/yep" // ModelsPath is the go import path of the yep/models package ModelsPath string = "github.com/npiganeau/yep/yep/models" // TypesPath is the go import path of the yep/models/types package TypesPath string = "github.com/npiganeau/yep/yep/models/types" // GeneratePath is the go import path of this package GeneratePath string = "github.com/npiganeau/yep/yep/tools/generate" // PoolPath is the go import path of the autogenerated pool package PoolPath string = "github.com/npiganeau/yep/pool" )
Variables ¶
var ( // YEPDir is the directory of the base yep package YEPDir string )
Functions ¶
func CreateFileFromTemplate ¶
CreateFileFromTemplate generates a new file from the given template and data
func CreatePool ¶
CreatePool generates the pool package by parsing the source code AST of the given program. The generated package will be put in the given dir.
func GetModelsASTData ¶
func GetModelsASTData(program *loader.Program) map[string]ModelASTData
GetModelsASTData returns the ModelASTData of all models found when parsing program.
func GetModelsASTDataForModules ¶
func GetModelsASTDataForModules(modInfos []*ModuleInfo) map[string]ModelASTData
GetModelsASTDataForModules returns the MethodASTData for all methods in given modules.
func GetModulePaths ¶
GetModulePaths returns the list of paths of all packages that are part of a module.
Types ¶
type FieldASTData ¶
A FieldASTData is a holder for a field's data that will be used for pool code generation
type MethodASTData ¶
type MethodASTData struct { Name string Doc string PkgPath string Params []ParamData Returns []TypeData }
A MethodASTData is a holder for a method's data that will be used for pool code generation
type ModelASTData ¶
type ModelASTData struct { Name string Fields map[string]FieldASTData Methods map[string]MethodASTData Mixins map[string]bool Embeds map[string]bool }
A ModelASTData holds fields and methods data of a Model
type ModuleInfo ¶
type ModuleInfo struct { loader.PackageInfo ModType PackageType }
A ModuleInfo is a wrapper around loader.Package with additional data to describe a module.
func GetModulePackages ¶
func GetModulePackages(program *loader.Program) []*ModuleInfo
GetModulePackages returns a slice of PackageInfo for packages that are yep modules, that is: - A package that declares a "MODULE_NAME" constant - A package that is in a subdirectory of a package Also returns the 'yep/models' package since all models are initialized there
func NewModuleInfo ¶
func NewModuleInfo(pack *loader.PackageInfo, modType PackageType) *ModuleInfo
NewModuleInfo returns a pointer to a new moduleInfo instance
type PackageType ¶
type PackageType int8
A PackageType describes a type of module
const ( // Base is the PackageType for the base package of a module Base PackageType = iota // Subs is the PackageType for a sub package of a module Subs // Models is the PackageType for the yep/models package Models )