generator

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The function from Effe, which declares flow
	BuildFLowExprType = "BuildFlow"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Drawer

type Drawer interface {
	// DrawBuild takes a list of compoments and a failure components, returns
	// string in plantuml dsl
	DrawFlow([]types.Component, types.Component) (string, error)
}

Drawe draws graphs for business flows.

type Generator

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

Generator loads dsl, generates code or diagrams.

func NewGenerator

func NewGenerator(opts ...Option) *Generator

Initialize a new generator with options

func (*Generator) Generate

func (g *Generator) Generate(ctx context.Context, wd string, env []string, patterns []string) ([]types.GenerateResult, []error)

This method generates code for a directory and environments.

func (*Generator) GenerateDiagram

func (g *Generator) GenerateDiagram(ctx context.Context, wd string, env []string, patterns []string, outputDir string) ([]types.GenerateResult, []error)

This method generates diagrams for a package

type Loader

type Loader interface {
	// Convert expressions to Components. Returns array of Components and a component with type Failure.
	LoadFlow([]ast.Expr, map[string]*ast.FuncDecl) ([]types.Component, types.Component, error)
}

Loader executes parsers for components by type. Generator gets arguments from expression BuildFlow and passes to Loader.

type Option

type Option func(g *Generator)

func WithDrawer

func WithDrawer(d Drawer) Option

WithDrawer is used for overriding a drawer

func WithLoader

func WithLoader(l Loader) Option

WithDrawer is used for overriding a loader

func WithSetttings

func WithSetttings(s Settings) Option

WithSetttings is used for overriding settings Default is settings from a method DefaultSettings()

func WithStrategy

func WithStrategy(s Strategy) Option

WithDrawer is used for overriding a strategy

type Settings

type Settings interface {
	FlowFuncPostfix() string
	LocalInterfaceVarname() string
	ImplFieldPostfix() string
	NewImplFuncPrefix() string
	ImplPostfix() string
	InterfaceNamePostfix() string
}

Settings for Generator

func DefaultSettigs

func DefaultSettigs() Settings

Default values for settings

type Strategy

type Strategy interface {
	// BuildFlow takes a list of components and a failure component and returns
	// the flow function and an array of imports.sss
	BuildFlow([]types.Component, types.Component, *goTypes.Info) (ast.Expr, []string, error)
}

Strategy generates the flow function.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL