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 CommentBlockDeclaration
- 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 FunctionDecl
- type FunctionExpression
- func (f *FunctionExpression) AddParams(params ...ParamDeclaration) *FunctionExpression
- func (f *FunctionExpression) AppendToBody(lines ...Writable) *FunctionExpression
- func (f *FunctionExpression) Arrow() *FunctionExpression
- func (f *FunctionExpression) Async() *FunctionExpression
- func (f *FunctionExpression) ReturnType(returnType Writable) *FunctionExpression
- func (f *FunctionExpression) TypeConstructor(typeConstructor Writable) *FunctionExpression
- func (f *FunctionExpression) WriteCode(writer CodeWriter)
- type IfStatement
- 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) Static() *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 OTBSBlock
- type ObjProp
- type ObjectType
- type ObjectValue
- 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 PropertySig
- type TypeDeclaration
- type UnionTypeRef
- 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 VarDeclaration
- type Writable
- type WritableCode
Constants ¶
This section is empty.
Variables ¶
var ( // Const declares a constant Const = declFact(constDecl) // Let declares a `let` variable Let = declFact(letDecl) // Var declares a `var` variable Var = declFact(varDecl) )
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) Len ¶
func (b *BlockDeclaration) Len() int
Len returns the number of lines defined in the block
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) OpenBlock() CloseBlock() }
type CommentBlockDeclaration ¶
type CommentBlockDeclaration struct {
// contains filtered or unexported fields
}
func CommentBlock ¶
func CommentBlock(lines ...string) *CommentBlockDeclaration
func (*CommentBlockDeclaration) AddComments ¶
func (self *CommentBlockDeclaration) AddComments(lines ...string) *CommentBlockDeclaration
func (*CommentBlockDeclaration) WriteComments ¶
func (self *CommentBlockDeclaration) WriteComments(writer CodeWriter)
type EnumDeclaration ¶
type EnumDeclaration struct { CommentBlockDeclaration // 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 { CommentBlockDeclaration // 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 FunctionDecl ¶
type FunctionDecl struct { Name string CommentBlockDeclaration FunctionExpression // contains filtered or unexported fields }
FunctionDecl represents a top level declaration.
func DeclareFunction ¶
func DeclareFunction(name string) *FunctionDecl
DeclareFunction returns a new function with the specified name
func (*FunctionDecl) AddParams ¶
func (f *FunctionDecl) AddParams(params ...ParamDeclaration) *FunctionDecl
AddParams add parameters to the function signiture
func (*FunctionDecl) Export ¶
func (f *FunctionDecl) Export() *FunctionDecl
Export exports the function declaration
func (*FunctionDecl) GetExpression ¶
func (fd *FunctionDecl) GetExpression() *FunctionExpression
GetExpression returns the associated function expression
func (*FunctionDecl) WriteCode ¶
func (f *FunctionDecl) WriteCode(writer CodeWriter)
WriteCode implements Writable
type FunctionExpression ¶
type FunctionExpression struct {
// contains filtered or unexported fields
}
FunctionExpression represents the function as an expression
func NewFunctionExpression ¶
func NewFunctionExpression() *FunctionExpression
NewFunctionExpression crates a new function expression struct
func (*FunctionExpression) AddParams ¶
func (f *FunctionExpression) AddParams(params ...ParamDeclaration) *FunctionExpression
AddParams add parameters to function expression call signature
func (*FunctionExpression) AppendToBody ¶
func (f *FunctionExpression) AppendToBody(lines ...Writable) *FunctionExpression
AppendToBody appends lines of code to the body of the function expression
func (*FunctionExpression) Arrow ¶
func (f *FunctionExpression) Arrow() *FunctionExpression
SetAsync configures function expression use arrow syntax
func (*FunctionExpression) Async ¶
func (f *FunctionExpression) Async() *FunctionExpression
Async configures function expression to be async
func (*FunctionExpression) ReturnType ¶
func (f *FunctionExpression) ReturnType(returnType Writable) *FunctionExpression
ReturnType sets the type constructor for the function expression
func (*FunctionExpression) TypeConstructor ¶
func (f *FunctionExpression) TypeConstructor(typeConstructor Writable) *FunctionExpression
TypeConstructor sets the type constructor for the function expression
func (*FunctionExpression) WriteCode ¶
func (f *FunctionExpression) WriteCode(writer CodeWriter)
WriteCode implements Writable
type IfStatement ¶
type IfStatement struct {
// contains filtered or unexported fields
}
IfStatement represents an if/else statement block
func If ¶
func If(cond Writable) *IfStatement
func (*IfStatement) ElseBlockAppend ¶
func (ifB *IfStatement) ElseBlockAppend(lines ...Writable) *IfStatement
func (*IfStatement) IfBlockAppend ¶
func (ifB *IfStatement) IfBlockAppend(lines ...Writable) *IfStatement
func (*IfStatement) WriteCode ¶
func (ifS *IfStatement) WriteCode(writer CodeWriter)
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 { CommentBlockDeclaration // 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 { CommentBlockDeclaration // 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) Static ¶
func (method *MethodDeclaration) Static() *MethodDeclaration
Static marks the method as static
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 OTBSBlock ¶
type OTBSBlock struct {
BlockDeclaration
}
OTBSBlock https://en.wikipedia.org/wiki/Indentation_style#Variant:_1TBS_.28OTBS.29
func (*OTBSBlock) WriteCode ¶
func (b *OTBSBlock) WriteCode(writer CodeWriter)
type ObjProp ¶
ObjProp represent a named property with a value on an object
func (*ObjProp) WriteCode ¶
func (ps *ObjProp) WriteCode(writer CodeWriter)
type ObjectType ¶
type ObjectType struct {
BlockDeclaration
}
ObjectType represents the object literal type
func NewObjectType ¶
func NewObjectType() *ObjectType
func (*ObjectType) AddProp ¶
func (o *ObjectType) AddProp(prop *PropertySig) *ObjectType
AddProp adds a property to the object type
func (*ObjectType) WriteCode ¶
func (t *ObjectType) WriteCode(writer CodeWriter)
WriteCode implements Writable
type ObjectValue ¶
type ObjectValue struct { BlockDeclaration // contains filtered or unexported fields }
ObjectValue represents a javascript object
func NewObjectValue ¶
func NewObjectValue() *ObjectValue
func (*ObjectValue) AddProp ¶
func (o *ObjectValue) AddProp(name string, value Writable) *ObjectValue
AddProp add a property
func (*ObjectValue) AddSpread ¶
func (o *ObjectValue) AddSpread(objectNameToSpread string, postPropertyAssignment bool) *ObjectValue
func (*ObjectValue) WriteCode ¶
func (t *ObjectValue) WriteCode(writer CodeWriter)
WriteCode implements Writable
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 { CommentBlockDeclaration // 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 PropertySig ¶
type PropertySig struct { Name string Optional bool TypeAnnotation Writable CommentBlockDeclaration }
PropertySig represents named type properties of object literal types
func (*PropertySig) WriteCode ¶
func (ps *PropertySig) WriteCode(writer CodeWriter)
WriteCode implements Writable
type TypeDeclaration ¶
type TypeDeclaration struct { CommentBlockDeclaration // contains filtered or unexported fields }
TypeDeclaration declares a type
func DeclareType ¶
func DeclareType(name string, typeRef Writable) *TypeDeclaration
DeclareType instantiates a new type declaration
func (*TypeDeclaration) Export ¶
func (td *TypeDeclaration) Export() *TypeDeclaration
func (*TypeDeclaration) WriteCode ¶
func (td *TypeDeclaration) WriteCode(writer CodeWriter)
WriteCode writes the type declaration to the writer
type UnionTypeRef ¶
type UnionTypeRef struct {
// contains filtered or unexported fields
}
UnionTypeRef represents the union of a series of type refs see: https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html#unions
func UnionType ¶
func UnionType(refs ...string) *UnionTypeRef
UnionType is a constructor function for creating union types
func (*UnionTypeRef) Union ¶
func (utr *UnionTypeRef) Union(ref Writable) *UnionTypeRef
func (*UnionTypeRef) WriteCode ¶
func (utr *UnionTypeRef) WriteCode(writer CodeWriter)
WriteCode writes the union type ref 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 VarDeclaration ¶
type VarDeclaration struct {
// contains filtered or unexported fields
}
VarDeclaration represents a variable declaration
func (*VarDeclaration) Export ¶
func (d *VarDeclaration) Export() *VarDeclaration
Export exports the variable
func (*VarDeclaration) WriteCode ¶
func (d *VarDeclaration) WriteCode(writer CodeWriter)
WriteCode implements Writable
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) String ¶
func (wc *WritableCode) String() string
func (*WritableCode) WriteCode ¶
func (wc *WritableCode) WriteCode(writer CodeWriter)