Documentation ¶
Index ¶
- Variables
- type DefaultJSDocument
- func (p *DefaultJSDocument) AddImport(dependency *ImportDependency) []*ImportDependency
- func (p *DefaultJSDocument) AddOther(new string) []string
- func (p *DefaultJSDocument) AddSerializable(s JSSerialize)
- func (p *DefaultJSDocument) DefaultExport() *JsDocumentScope
- func (p *DefaultJSDocument) Extension() string
- func (p *DefaultJSDocument) Imports() []*ImportDependency
- func (p *DefaultJSDocument) Key() string
- func (p *DefaultJSDocument) Name() string
- func (p *DefaultJSDocument) Other() []string
- func (p *DefaultJSDocument) WriteFile(dir string) error
- type EmptyParser
- type FunctionDefinition
- type ImportDependency
- type ImportType
- type JSDocArgList
- type JSDocument
- type JSExport
- type JSFileParser
- type JSParser
- type JSSerialize
- type JSToken
- type JSType
- type JsDocFunc
- type JsDocSwitch
- type JsDocumentScope
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrFunctionExport = errors.New("function export cannot be the name of the default export")
View Source
var ErrInvalidName = errors.New("variable name is invalid")
Functions ¶
This section is empty.
Types ¶
type DefaultJSDocument ¶
type DefaultJSDocument struct {
// contains filtered or unexported fields
}
DefaultJSDocument is a struct that implements the JSDocument interface this struct can be used as an output for JSDocument parsing.
func NewDocument ¶
func NewDocument(webDir string, pageDir string) *DefaultJSDocument
NewDocument creates a new JS document
func NewEmptyDocument ¶
func NewEmptyDocument() *DefaultJSDocument
NewEmptyDocument creates a new empty JSDocument
func NewImportDocument ¶ added in v0.7.0
func NewImportDocument(imports ...*ImportDependency) *DefaultJSDocument
func (*DefaultJSDocument) AddImport ¶
func (p *DefaultJSDocument) AddImport(dependency *ImportDependency) []*ImportDependency
func (*DefaultJSDocument) AddOther ¶
func (p *DefaultJSDocument) AddOther(new string) []string
func (*DefaultJSDocument) AddSerializable ¶ added in v0.7.0
func (p *DefaultJSDocument) AddSerializable(s JSSerialize)
func (*DefaultJSDocument) DefaultExport ¶ added in v0.7.0
func (p *DefaultJSDocument) DefaultExport() *JsDocumentScope
func (*DefaultJSDocument) Extension ¶
func (p *DefaultJSDocument) Extension() string
func (*DefaultJSDocument) Imports ¶
func (p *DefaultJSDocument) Imports() []*ImportDependency
func (*DefaultJSDocument) Key ¶
func (p *DefaultJSDocument) Key() string
func (*DefaultJSDocument) Name ¶
func (p *DefaultJSDocument) Name() string
func (*DefaultJSDocument) Other ¶
func (p *DefaultJSDocument) Other() []string
func (*DefaultJSDocument) WriteFile ¶
func (p *DefaultJSDocument) WriteFile(dir string) error
type EmptyParser ¶
type EmptyParser struct {
BadParse bool
}
func (*EmptyParser) Parse ¶
func (p *EmptyParser) Parse(string, string) (JSDocument, error)
type FunctionDefinition ¶
FunctionDefinition is a light-weight struct to define JS function definition
type ImportDependency ¶
type ImportDependency struct { FinalStatement string InitialPath string Type ImportType }
ImportDependency represents an entire import path within a javascript file.
type ImportType ¶
type ImportType int32
ImportType represents a javascript import type
const ( // LocalImportType represents an import that appears to be a local module // e.g import Thing from '../stuff/help.js' LocalImportType ImportType = 0 // ModuleImportType represents an import that appears to be located in // as a node module. e.g import Thing from '@someorg/help.js' ModuleImportType ImportType = 1 )
type JSDocArgList ¶ added in v0.7.0
type JSDocArgList []string
func (JSDocArgList) ToString ¶ added in v0.7.0
func (s JSDocArgList) ToString() string
type JSDocument ¶
type JSDocument interface { WriteFile(string) error Key() string Imports() []*ImportDependency AddImport(*ImportDependency) []*ImportDependency Other() []string AddOther(string) []string Extension() string AddSerializable(s JSSerialize) Name() string DefaultExport() *JsDocumentScope }
JSDocument is an interface that describes the behavior of a JSDocument
type JSFileParser ¶
type JSFileParser struct{}
func (*JSFileParser) Parse ¶
func (p *JSFileParser) Parse(pageDir string, webDir string) (JSDocument, error)
type JSSerialize ¶ added in v0.7.0
type JSSerialize interface {
Serialize() string
}
type JSToken ¶
type JSToken string
JSToken is some keyword(s) found in javascript used to tokenize js documents.
type JsDocFunc ¶ added in v0.7.0
type JsDocFunc struct { Declaration string // contains filtered or unexported fields }
func NewFunc ¶ added in v0.7.0
func NewFunc(declaration string, body JSSerialize) *JsDocFunc
type JsDocSwitch ¶ added in v0.7.0
type JsDocSwitch struct {
// contains filtered or unexported fields
}
func NewSwitch ¶ added in v0.7.0
func NewSwitch(varname string) *JsDocSwitch
func (*JsDocSwitch) Add ¶ added in v0.7.0
func (s *JsDocSwitch) Add(t JSType, value string, body string)
func (*JsDocSwitch) Serialize ¶ added in v0.7.0
func (s *JsDocSwitch) Serialize() string
type JsDocumentScope ¶ added in v0.7.0
type JsDocumentScope struct { TokenType JSToken Name string Export JSExport Args JSDocArgList }
Click to show internal directories.
Click to hide internal directories.