Documentation ¶
Index ¶
- type Annotation
- type ArrayType
- type ConstBlockType
- type ControllerGenerator
- type ControllerGeneratorMode
- type File
- func (f *File) AddFunction(data string) error
- func (f *File) AddImport(name string)
- func (f *File) AddNode(node Node)
- func (f *File) Merge(source *File) error
- func (f *File) Name() string
- func (f *File) Node() *dst.File
- func (f *File) ReadFrom(r io.Reader) (int64, error)
- func (f *File) Sync() error
- func (f *File) WriteTo(w io.Writer) (int64, error)
- type FileGenerator
- type Generator
- type LiteralType
- type MainGenerator
- type Merger
- type Node
- type Range
- type SchemaGenerator
- type ServerGenerator
- type SpecGenerator
- type StructType
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Annotation ¶
type Annotation string
Annotation represents an annotation
const ( // AnnotationGenerate represents the annotation for tgenerated code AnnotationGenerate Annotation = "stride:generate" // AnnotationDefine represents the annotation for user-defined code AnnotationDefine Annotation = "stride:define" // AnnotationNotice represents the annotation for note AnnotationNotice Annotation = "NOTE:" )
func (Annotation) Comment ¶
func (n Annotation) Comment(text string) string
Comment formats the annotation as comment
func (Annotation) Find ¶
func (n Annotation) Find(decorations dst.Decorations) (string, bool)
Find returns the name of the annotation of exists in the decorations
func (Annotation) In ¶
func (n Annotation) In(decorations dst.Decorations, term string) bool
In returns true if the annotation with given name exists in the decorations list
func (Annotation) Key ¶
func (n Annotation) Key(text ...string) string
Key formats the annotation as key
type ArrayType ¶
type ArrayType struct {
// contains filtered or unexported fields
}
ArrayType builds an array type
type ConstBlockType ¶
type ConstBlockType struct {
// contains filtered or unexported fields
}
ConstBlockType builds a var block type
func NewConstBlockType ¶
func NewConstBlockType() *ConstBlockType
NewConstBlockType creates a new ConstBlcokType
func (*ConstBlockType) AddConst ¶
func (b *ConstBlockType) AddConst(name, kind, value string)
AddConst defines a var
func (*ConstBlockType) Commentf ¶
func (b *ConstBlockType) Commentf(pattern string, args ...interface{})
Commentf adds a comment
type ControllerGenerator ¶
type ControllerGenerator struct { Path string Mode ControllerGeneratorMode Controller *codedom.ControllerDescriptor Reporter contract.Reporter }
ControllerGenerator builds a controller
func (*ControllerGenerator) Generate ¶
func (g *ControllerGenerator) Generate() *File
Generate generates a file
type ControllerGeneratorMode ¶
type ControllerGeneratorMode byte
ControllerGeneratorMode determines the mode of this generator
const ( // ControllerGeneratorModeSchema generates the schema for the controller ControllerGeneratorModeSchema ControllerGeneratorMode = 0 // ControllerGeneratorModeAPI generates the api for the controller ControllerGeneratorModeAPI ControllerGeneratorMode = 1 // ControllerGeneratorModeSpec generates the spec for the controller ControllerGeneratorModeSpec ControllerGeneratorMode = 2 )
type File ¶
type File struct {
// contains filtered or unexported fields
}
File represents the generated file
func (*File) AddFunction ¶
AddFunction adds a function
type FileGenerator ¶
type FileGenerator interface { // Generate generates the file Generate() *File }
FileGenerator is a file generator
type LiteralType ¶
type LiteralType struct {
// contains filtered or unexported fields
}
LiteralType builds a literal type
func NewLiteralType ¶
func NewLiteralType(name string) *LiteralType
NewLiteralType creates a new literal type builder
func (*LiteralType) Commentf ¶
func (b *LiteralType) Commentf(pattern string, args ...interface{})
Commentf adds a comment
func (*LiteralType) Element ¶
func (b *LiteralType) Element(name string) *LiteralType
Element sets the element
type MainGenerator ¶
MainGenerator builds the main
type SchemaGenerator ¶
type SchemaGenerator struct { Path string Collection codedom.TypeDescriptorCollection Reporter contract.Reporter }
SchemaGenerator generates a contract
func (*SchemaGenerator) Generate ¶
func (g *SchemaGenerator) Generate() *File
Generate generates the file
type ServerGenerator ¶
type ServerGenerator struct { Path string Controllers codedom.ControllerDescriptorCollection Reporter contract.Reporter }
ServerGenerator builds a server
func (*ServerGenerator) Generate ¶
func (g *ServerGenerator) Generate() *File
Generate generates a file
type SpecGenerator ¶
SpecGenerator builds the main
type StructType ¶
type StructType struct {
// contains filtered or unexported fields
}
StructType builds a struct
func NewStructType ¶
func NewStructType(name string) *StructType
NewStructType creates a new struct type builder
func (*StructType) AddField ¶
func (b *StructType) AddField(name, kind string, tags ...*codedom.TagDescriptor)
AddField defines a field
func (*StructType) Commentf ¶
func (b *StructType) Commentf(pattern string, args ...interface{})
Commentf adds a comment
func (*StructType) HasFields ¶
func (b *StructType) HasFields() bool
HasFields return true if the struct has fields