gen

package
Version: v0.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2021 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(pkgPath string, opts *ParserGoPkgOpts) error

Run will create a new ParserGoPkg and call Run on it.

func RunRecursive

func RunRecursive(pkgPath string, opts *ParserGoPkgOpts) error

RunRecursive will create a new ParserGoPkg and call Run on it recursively for each directory under pkgPath. The opts will be modified for subfolders to disable go.mod and main.go logic. If pkgPath does not contain a .vugu file this function will return an error.

Types

type ParserGo

type ParserGo struct {
	PackageName string // name of package to use at top of files
	StructType  string // just the struct name, no "*" (replaces ComponentType and DataType)
	// ComponentType string // just the struct name, no "*"
	// DataType      string // just the struct name, no "*"
	OutDir  string // output dir
	OutFile string // output file name with ".go" suffix

	NoOptimizeStatic bool // set to true to disable optimization of static blocks of HTML into vg-html expressions
	TinyGo           bool // set to true to enable TinyGo compatability changes to the generated code
}

ParserGo is a template parser that emits Go source code that will construct the appropriately wired VGNodes.

func (*ParserGo) Parse

func (p *ParserGo) Parse(r io.Reader, fname string) error

Parse is an experiment... r is the actual input, fname is only used to emit line directives

type ParserGoPkg

type ParserGoPkg struct {
	// contains filtered or unexported fields
}

ParserGoPkg knows how to perform source file generation in relation to a package folder. Whereas ParserGo handles converting a single template, ParserGoPkg is a higher level interface and provides the functionality of the vugugen command line tool. It will scan a package folder for .vugu files and convert them to .go, with the appropriate defaults and logic.

func NewParserGoPkg

func NewParserGoPkg(pkgPath string, opts *ParserGoPkgOpts) *ParserGoPkg

NewParserGoPkg returns a new ParserGoPkg with the specified options or default if nil. The pkgPath is required and must be an absolute path.

func (*ParserGoPkg) Opts

func (p *ParserGoPkg) Opts() ParserGoPkgOpts

Opts returns the options.

func (*ParserGoPkg) Run

func (p *ParserGoPkg) Run() error

Run does the work and generates the appropriate .go files from .vugu files. It will also create a go.mod file if not present and not SkipGoMod. Same for main.go and SkipMainGo (will also skip if package already has file with package name something other than main). Per-file code generation is performed by ParserGo.

type ParserGoPkgOpts

type ParserGoPkgOpts struct {
	SkipGoMod        bool    // do not try and create go.mod if it doesn't exist
	SkipMainGo       bool    // do not try and create main_wasm.go if it doesn't exist in a main package
	TinyGo           bool    // emit code intended for TinyGo compilation
	GoFileNameAppend *string // suffix to append to file names, after base name plus .go, if nil then "_vgen" is used
	MergeSingle      bool    // merge all output files into a single one
	MergeSingleName  string  // name of merged output file, only used if MergeSingle is true, defaults to "0_components_vgen.go"
}

ParserGoPkgOpts is the options for ParserGoPkg.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto