Documentation ¶
Index ¶
- Variables
- func CreateWriter() codeWriter
- type BlockDeclaration
- type ClassDeclaration
- func (cls *ClassDeclaration) AddMembers(members ...Writable) *ClassDeclaration
- func (cls *ClassDeclaration) Constructor() *MethodDeclaration
- func (cls *ClassDeclaration) Export() *ClassDeclaration
- func (cls *ClassDeclaration) Extends(types ...string) *ClassDeclaration
- func (cls *ClassDeclaration) Implements(types ...string) *ClassDeclaration
- func (cls *ClassDeclaration) Method(name string) *MethodDeclaration
- func (cls *ClassDeclaration) Private() *ClassDeclaration
- func (cls *ClassDeclaration) Property(typeName string, name string) *PropertyDeclaration
- func (cls *ClassDeclaration) Public() *ClassDeclaration
- func (cls *ClassDeclaration) WriteCode(writer CodeWriter)
- type CodeWriter
- type EnumDeclaration
- func (enum *EnumDeclaration) AddMembers(members ...Writable) *EnumDeclaration
- func (enum *EnumDeclaration) Const() *EnumDeclaration
- func (enum *EnumDeclaration) Export() *EnumDeclaration
- func (enum *EnumDeclaration) Member(name string) *EnumMemberDeclaration
- func (enum *EnumDeclaration) WriteCode(writer CodeWriter)
- type EnumMemberDeclaration
- type ImportDeclaration
- type InterfaceDeclaration
- func (iface *InterfaceDeclaration) AddMembers(members ...Writable) *InterfaceDeclaration
- func (iface *InterfaceDeclaration) Export() *InterfaceDeclaration
- func (iface *InterfaceDeclaration) Extends(types ...string) *InterfaceDeclaration
- func (iface *InterfaceDeclaration) Method(name string) *MethodDeclaration
- func (iface *InterfaceDeclaration) Property(typeName string, name string) *PropertyDeclaration
- func (iface *InterfaceDeclaration) WriteCode(writer CodeWriter)
- type MethodDeclaration
- func (method *MethodDeclaration) AddParams(params ...Writable) *MethodDeclaration
- func (method *MethodDeclaration) Async() *MethodDeclaration
- func (method *MethodDeclaration) Body(lines ...string) *BlockDeclaration
- func (method *MethodDeclaration) Param(typeName string, name string) *ParamDeclaration
- func (method *MethodDeclaration) Private() *MethodDeclaration
- func (method *MethodDeclaration) Public() *MethodDeclaration
- func (method *MethodDeclaration) Returns(returnType string) *MethodDeclaration
- func (method *MethodDeclaration) WriteCode(writer CodeWriter)
- type NamespaceDeclaration
- func (ns *NamespaceDeclaration) AddDeclarations(declarations ...Writable) *NamespaceDeclaration
- func (ns *NamespaceDeclaration) AddImports(imports ...Writable) *NamespaceDeclaration
- func (ns *NamespaceDeclaration) DefaultImport(module string, as string) *NamespaceDeclaration
- func (ns *NamespaceDeclaration) NamedImport(module string, params ...string) *NamespaceDeclaration
- func (ns *NamespaceDeclaration) WithReference(filePath string) *NamespaceDeclaration
- func (ns *NamespaceDeclaration) WriteCode(writer CodeWriter)
- type ParamDeclaration
- func (param *ParamDeclaration) Default(defaultValue Writable) *ParamDeclaration
- func (param *ParamDeclaration) Private() *ParamDeclaration
- func (param *ParamDeclaration) Public() *ParamDeclaration
- func (param *ParamDeclaration) Readonly() *ParamDeclaration
- func (param *ParamDeclaration) WriteCode(writer CodeWriter)
- type PropertyDeclaration
- func (prop *PropertyDeclaration) Initializer(initializer string) *PropertyDeclaration
- func (prop *PropertyDeclaration) Optional() *PropertyDeclaration
- func (prop *PropertyDeclaration) Private() *PropertyDeclaration
- func (prop *PropertyDeclaration) Public() *PropertyDeclaration
- func (prop *PropertyDeclaration) Readonly() *PropertyDeclaration
- func (prop *PropertyDeclaration) Static() *PropertyDeclaration
- func (prop *PropertyDeclaration) WriteCode(writer CodeWriter)
- type UnitDeclaration
- func (unit *UnitDeclaration) AddDeclarations(declarations ...Writable) *UnitDeclaration
- func (unit *UnitDeclaration) AddImports(imports ...Writable) *UnitDeclaration
- func (unit *UnitDeclaration) AddNamespaces(namespaces ...Writable) *UnitDeclaration
- func (unit *UnitDeclaration) Code() string
- func (unit *UnitDeclaration) DefaultImport(module string, as string) *UnitDeclaration
- func (unit *UnitDeclaration) NamedImport(module string, params ...string) *UnitDeclaration
- func (unit *UnitDeclaration) Namespace(namespace string) *NamespaceDeclaration
- func (unit *UnitDeclaration) WriteCode(writer CodeWriter)
- type Writable
- type WritableCode
Constants ¶
This section is empty.
Variables ¶
var False = Code("false")
var Null = Code("null")
var True = Code("true")
var Undefined = Code("undefined")
Functions ¶
func CreateWriter ¶
func CreateWriter() codeWriter
Types ¶
type BlockDeclaration ¶
type BlockDeclaration struct {
// contains filtered or unexported fields
}
func Block ¶
func Block(lines ...string) *BlockDeclaration
func (*BlockDeclaration) Append ¶
func (self *BlockDeclaration) Append(code string) *BlockDeclaration
func (*BlockDeclaration) AppendCode ¶
func (self *BlockDeclaration) AppendCode(code Writable) *BlockDeclaration
func (*BlockDeclaration) WriteCode ¶
func (self *BlockDeclaration) WriteCode(writer CodeWriter)
type ClassDeclaration ¶
type ClassDeclaration struct {
// contains filtered or unexported fields
}
ClassDeclaration declares a class
func Class ¶
func Class(name string) *ClassDeclaration
Class starts building a new class. returns ClassDeclaration
func (*ClassDeclaration) AddMembers ¶
func (cls *ClassDeclaration) AddMembers(members ...Writable) *ClassDeclaration
AddMembers adds methods or properties to a class
func (*ClassDeclaration) Constructor ¶
func (cls *ClassDeclaration) Constructor() *MethodDeclaration
Constructor starts building a constructor on the class. returns MethodDeclaration
func (*ClassDeclaration) Export ¶
func (cls *ClassDeclaration) Export() *ClassDeclaration
Exported marks a class as exported
func (*ClassDeclaration) Extends ¶
func (cls *ClassDeclaration) Extends(types ...string) *ClassDeclaration
Extends adds types that the classes extends
func (*ClassDeclaration) Implements ¶
func (cls *ClassDeclaration) Implements(types ...string) *ClassDeclaration
Implements adds types that the classes implements
func (*ClassDeclaration) Method ¶
func (cls *ClassDeclaration) Method(name string) *MethodDeclaration
Method starts building a new method on the class. returns MethodDeclaration
func (*ClassDeclaration) Private ¶
func (cls *ClassDeclaration) Private() *ClassDeclaration
Private marks a class as private
func (*ClassDeclaration) Property ¶
func (cls *ClassDeclaration) Property(typeName string, name string) *PropertyDeclaration
Property adds a property to the class. returns PropertyDeclaration
func (*ClassDeclaration) Public ¶
func (cls *ClassDeclaration) Public() *ClassDeclaration
Public marks a class as public
func (*ClassDeclaration) WriteCode ¶
func (cls *ClassDeclaration) WriteCode(writer CodeWriter)
WriteCode writes the class to the writer
type CodeWriter ¶
type CodeWriter interface { Begin() End() Eol() Write(code string) }
type EnumDeclaration ¶
type EnumDeclaration struct {
// contains filtered or unexported fields
}
EnumDeclaration declares an enum
func Enum ¶
func Enum(name string) *EnumDeclaration
Enum starts building a new enum. returns EnumDeclaration
func (*EnumDeclaration) AddMembers ¶
func (enum *EnumDeclaration) AddMembers(members ...Writable) *EnumDeclaration
AddMembers adds members to the enum
func (*EnumDeclaration) Const ¶
func (enum *EnumDeclaration) Const() *EnumDeclaration
Const makes the enum a constant
func (*EnumDeclaration) Export ¶
func (enum *EnumDeclaration) Export() *EnumDeclaration
Exported makes the enum a exported
func (*EnumDeclaration) Member ¶
func (enum *EnumDeclaration) Member(name string) *EnumMemberDeclaration
Member adds a member to the enum. returns EnumMemberDeclaration
func (*EnumDeclaration) WriteCode ¶
func (enum *EnumDeclaration) WriteCode(writer CodeWriter)
WriteCode writes the enum to the writer
type EnumMemberDeclaration ¶
type EnumMemberDeclaration struct {
// contains filtered or unexported fields
}
EnumMemberDeclaration declares an enum member
func EnumMember ¶
func EnumMember(name string) *EnumMemberDeclaration
EnumMember creates a new enum member
func (*EnumMemberDeclaration) Value ¶
func (enum *EnumMemberDeclaration) Value(value *WritableCode) *EnumMemberDeclaration
Value sets the enums value
func (*EnumMemberDeclaration) WriteCode ¶
func (enum *EnumMemberDeclaration) WriteCode(writer CodeWriter)
WriteCode writes the enum to the writer
type ImportDeclaration ¶
type ImportDeclaration struct {
// contains filtered or unexported fields
}
ImportDeclaration declares an import
func DefaultImport ¶
func DefaultImport(module string, as string) *ImportDeclaration
DefaultImport creates a default import. import * as foo from 'module';
func NamedImport ¶
func NamedImport(module string, params ...string) *ImportDeclaration
NamedImport creates a default import. import * as foo from 'module';
func (*ImportDeclaration) WriteCode ¶
func (imp *ImportDeclaration) WriteCode(writer CodeWriter)
WriteCode writes the imports to the writer
type InterfaceDeclaration ¶
type InterfaceDeclaration struct {
// contains filtered or unexported fields
}
InterfaceDeclaration declares an interface
func Interface ¶
func Interface(name string) *InterfaceDeclaration
Interface starts building a new interface. returns InterfaceDeclaration
func (*InterfaceDeclaration) AddMembers ¶
func (iface *InterfaceDeclaration) AddMembers(members ...Writable) *InterfaceDeclaration
AddMembers adds additional members to the interface
func (*InterfaceDeclaration) Export ¶
func (iface *InterfaceDeclaration) Export() *InterfaceDeclaration
Export marks the interface as exported
func (*InterfaceDeclaration) Extends ¶
func (iface *InterfaceDeclaration) Extends(types ...string) *InterfaceDeclaration
Extends adds additional types to extend the interface
func (*InterfaceDeclaration) Method ¶
func (iface *InterfaceDeclaration) Method(name string) *MethodDeclaration
Method starts building a new method on the interface. returns MethodDeclaration
func (*InterfaceDeclaration) Property ¶
func (iface *InterfaceDeclaration) Property(typeName string, name string) *PropertyDeclaration
Property starts building a new property on the interface. returns PropertyDeclaration
func (*InterfaceDeclaration) WriteCode ¶
func (iface *InterfaceDeclaration) WriteCode(writer CodeWriter)
WriteCode writes the interface to the writer
type MethodDeclaration ¶
type MethodDeclaration struct {
// contains filtered or unexported fields
}
MethodDeclaration declares an method
func Constructor ¶
func Constructor() *MethodDeclaration
Constructor starts building a new constructor. returns MethodDeclaration
func Method ¶
func Method(name string) *MethodDeclaration
Method starts building a new method. returns MethodDeclaration
func (*MethodDeclaration) AddParams ¶
func (method *MethodDeclaration) AddParams(params ...Writable) *MethodDeclaration
AddParams adds parameters to the method
func (*MethodDeclaration) Async ¶
func (method *MethodDeclaration) Async() *MethodDeclaration
Async marks the method as async
func (*MethodDeclaration) Body ¶
func (method *MethodDeclaration) Body(lines ...string) *BlockDeclaration
Body starts building the method body. returns BlockDeclaration
func (*MethodDeclaration) Param ¶
func (method *MethodDeclaration) Param(typeName string, name string) *ParamDeclaration
Param adds a parameter to the method
func (*MethodDeclaration) Private ¶
func (method *MethodDeclaration) Private() *MethodDeclaration
Private marks the method as private
func (*MethodDeclaration) Public ¶
func (method *MethodDeclaration) Public() *MethodDeclaration
Public marks the method as public
func (*MethodDeclaration) Returns ¶
func (method *MethodDeclaration) Returns(returnType string) *MethodDeclaration
Returns sets the return type of the method
func (*MethodDeclaration) WriteCode ¶
func (method *MethodDeclaration) WriteCode(writer CodeWriter)
WriteCode writes the method to the writer
type NamespaceDeclaration ¶
type NamespaceDeclaration struct {
// contains filtered or unexported fields
}
NamespaceDeclaration declares a namespace
func Namespace ¶
func Namespace(namespace string) *NamespaceDeclaration
Namespace creates a NamespaceDeclaration
func (*NamespaceDeclaration) AddDeclarations ¶
func (ns *NamespaceDeclaration) AddDeclarations(declarations ...Writable) *NamespaceDeclaration
AddDeclarations adds declarations to the namespace
func (*NamespaceDeclaration) AddImports ¶
func (ns *NamespaceDeclaration) AddImports(imports ...Writable) *NamespaceDeclaration
AddImports adds imports to the namespace
func (*NamespaceDeclaration) DefaultImport ¶
func (ns *NamespaceDeclaration) DefaultImport(module string, as string) *NamespaceDeclaration
DefaultImport adds a default import
func (*NamespaceDeclaration) NamedImport ¶
func (ns *NamespaceDeclaration) NamedImport(module string, params ...string) *NamespaceDeclaration
NamedImport adds a named import
func (*NamespaceDeclaration) WithReference ¶
func (ns *NamespaceDeclaration) WithReference(filePath string) *NamespaceDeclaration
WithReference adds a file reference for namespace compilation
func (*NamespaceDeclaration) WriteCode ¶
func (ns *NamespaceDeclaration) WriteCode(writer CodeWriter)
WriteCode writes the namespace to the writer
type ParamDeclaration ¶
type ParamDeclaration struct {
// contains filtered or unexported fields
}
ParamDeclaration declares an parameter
func Param ¶
func Param(typeName string, name string) *ParamDeclaration
Param creates a new ParamDeclaration
func (*ParamDeclaration) Default ¶
func (param *ParamDeclaration) Default(defaultValue Writable) *ParamDeclaration
Default sets the default value of the param
func (*ParamDeclaration) Private ¶
func (param *ParamDeclaration) Private() *ParamDeclaration
Private marks the parameter as private. Only for constructors
func (*ParamDeclaration) Public ¶
func (param *ParamDeclaration) Public() *ParamDeclaration
Public marks the parameter as public. Only for constructors
func (*ParamDeclaration) Readonly ¶
func (param *ParamDeclaration) Readonly() *ParamDeclaration
Readonly marks the parameter as readonly. Only for constructors
func (*ParamDeclaration) WriteCode ¶
func (param *ParamDeclaration) WriteCode(writer CodeWriter)
WriteCode writes the param to the writer
type PropertyDeclaration ¶
type PropertyDeclaration struct {
// contains filtered or unexported fields
}
PropertyDeclaration declares a property
func Property ¶
func Property(typeName string, name string) *PropertyDeclaration
Property starts building a new property. returns PropertyDeclaration
func (*PropertyDeclaration) Initializer ¶
func (prop *PropertyDeclaration) Initializer(initializer string) *PropertyDeclaration
Initializer sets the properties initializer
func (*PropertyDeclaration) Optional ¶
func (prop *PropertyDeclaration) Optional() *PropertyDeclaration
Optional marks the property as optional
func (*PropertyDeclaration) Private ¶
func (prop *PropertyDeclaration) Private() *PropertyDeclaration
Private marks the property as private
func (*PropertyDeclaration) Public ¶
func (prop *PropertyDeclaration) Public() *PropertyDeclaration
Public marks the property as public
func (*PropertyDeclaration) Readonly ¶
func (prop *PropertyDeclaration) Readonly() *PropertyDeclaration
Readonly marks the property as readonly
func (*PropertyDeclaration) Static ¶
func (prop *PropertyDeclaration) Static() *PropertyDeclaration
Static marks the property as static. Can only be used on classes, not interfaces
func (*PropertyDeclaration) WriteCode ¶
func (prop *PropertyDeclaration) WriteCode(writer CodeWriter)
WriteCode writes the property to the writer
type UnitDeclaration ¶
type UnitDeclaration struct {
// contains filtered or unexported fields
}
func Unit ¶
func Unit() *UnitDeclaration
func (*UnitDeclaration) AddDeclarations ¶
func (unit *UnitDeclaration) AddDeclarations(declarations ...Writable) *UnitDeclaration
AddDeclarations adds declarations to the unit
func (*UnitDeclaration) AddImports ¶
func (unit *UnitDeclaration) AddImports(imports ...Writable) *UnitDeclaration
func (*UnitDeclaration) AddNamespaces ¶
func (unit *UnitDeclaration) AddNamespaces(namespaces ...Writable) *UnitDeclaration
func (*UnitDeclaration) Code ¶
func (unit *UnitDeclaration) Code() string
func (*UnitDeclaration) DefaultImport ¶
func (unit *UnitDeclaration) DefaultImport(module string, as string) *UnitDeclaration
func (*UnitDeclaration) NamedImport ¶
func (unit *UnitDeclaration) NamedImport(module string, params ...string) *UnitDeclaration
func (*UnitDeclaration) Namespace ¶
func (unit *UnitDeclaration) Namespace(namespace string) *NamespaceDeclaration
func (*UnitDeclaration) WriteCode ¶
func (unit *UnitDeclaration) WriteCode(writer CodeWriter)
type Writable ¶
type Writable interface {
WriteCode(writer CodeWriter)
}
type WritableCode ¶
type WritableCode struct {
// contains filtered or unexported fields
}
func C ¶
func C(code string) *WritableCode
func Code ¶
func Code(code string) *WritableCode
func Int ¶
func Int(value int) *WritableCode
func Str ¶
func Str(value string) *WritableCode
func (*WritableCode) WriteCode ¶
func (self *WritableCode) WriteCode(writer CodeWriter)