Documentation ¶
Overview ¶
Package parser provides the ability to parse the data that is bound in Wails projects. Using this, it can also generate a Javascript module that represents the DTOs used, as well as providing wrappers for bound methods.
Index ¶
Constants ¶
const ( // JsString is a JS string JsString JSType = "string" // JsBoolean is a JS bool JsBoolean = "boolean" // JsInt is a JS number JsInt = "number" // JsFloat is a JS number JsFloat = "number" // JsArray is a JS array JsArray = "Array" // JsObject is a JS object JsObject = "Object" // JsUnsupported represents a type that cannot be converted JsUnsupported = "*" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Field ¶
type Field struct { // Name of the field Name string // The type of the field. // "struct" if it's a struct Type string // A pointer to the struct if the Type is "struct" Struct *Struct // User comments on the field Comments []string // Indicates if the Field is an array of type "Type" IsArray bool // JSON field name defined by a json tag JSONOptions }
Field defines a parsed struct field
func (*Field) AsTSDeclaration ¶
AsTSDeclaration returns a TS definition of a single type field
func (*Field) NameForPropertyDoc ¶
NameForPropertyDoc returns a formatted name for the jsdoc @property declaration
func (*Field) TypeAsTSType ¶
TypeAsTSType converts the Field type to something TS wants
func (*Field) TypeForPropertyDoc ¶
TypeForPropertyDoc returns a formatted name for the jsdoc @property declaration
type JSONOptions ¶
type Method ¶
Method defines a struct method
func (*Method) InputsAsJSText ¶
InputsAsJSText generates a string with the method inputs formatted in a way acceptable to Javascript
func (*Method) InputsAsTSText ¶
InputsAsTSText generates a string with the method inputs formatted in a way acceptable to Typescript
func (*Method) OutputsAsTSDeclarationText ¶
OutputsAsTSDeclarationText generates a string with the method inputs formatted in a way acceptable to Javascript
func (*Method) OutputsAsTSText ¶
OutputsAsTSText generates a string with the method inputs formatted in a way acceptable to Javascript
type Package ¶
type Package struct { // A unique Name for this package. // This is calculated and may not be the same as the one // defined in Go - but that's ok! Name string // the package we are wrapping Gopackage *packages.Package // contains filtered or unexported fields }
Package is a wrapper around the go parsed package
func (*Package) DeclarationReferences ¶
DeclarationReferences returns a list of external packages we reference from this package
func (*Package) HasBoundStructs ¶
HasBoundStructs returns true if any of its structs are bound
func (*Package) HasDataStructs ¶
HasDataStructs returns true if any of its structs are used as data
func (*Package) ShouldGenerate ¶
ShouldGenerate returns true when this package should be generated
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser is the Wails project parser
func (*Parser) ParseProject ¶
ParseProject will parse the Wails project in the given directory
type ParserReport ¶
type ParserReport struct {
Packages []*Package
}
func GenerateWailsFrontendPackage ¶
func GenerateWailsFrontendPackage() (*ParserReport, error)
GenerateWailsFrontendPackage will generate a Javascript/Typescript package in `<project>/frontend/wails` that defines which methods and structs are bound to your frontend
type Struct ¶
type Struct struct { // The name of the struct Name string // The package this was declared in Package *Package // Comments for the struct Comments []string // The fields used in this struct Fields []*Field // The methods available to the front end Methods []*Method // Indicates if this struct is bound to the app IsBound bool // Indicates if this struct is used as data IsUsedAsData bool }
Struct represents a struct that is used by the frontend in a Wails project