generator

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, customizer Customizer)

Register makes a Customizer available by name. If a Customizer by the same name is registered, an error is thrown.

Types

type Customizer

type Customizer interface {
	// FileNamePrefix gives a prefix for the generated file name.
	FileNamePrefix() string
	// FactorySuffix provides a variant typed suffix for a Factory method
	// generated for the middleware.
	FactorySuffix() string
	// ConfigureModel takes the given ServiceModel and can apply any specifications
	// such as desired inputs to the Factory method,
	ConfigureModel(model *ServiceModel)
	GetRequiredImportNames() map[string]string
	// GenerateFunctionImplementation will be passed in a builder
	// of pre-computed code statements as the function declaration
	// as described by the passed-in DeclaredFunction. It is important
	// to note that no code blocks have been created at this point, see
	// jen.Block for more details.
	GenerateFunctionImplementation(builder *jen.Statement, service *ServiceModel, method interpreter.DeclaredFunction) jen.Code
}

Customizer is utilized by Generator to specify the generated output of a desired middleware. Each instance should be registered with generator.Register.

type File

type File struct {
	Directory  string
	TypeName   string // Name of the constant type.
	Package    *packages.Package
	Middleware string
	Customizer string
}

type Generator

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

Generator is an object to take an interpreted interpreter.ServiceModel and using a Customizer, generates the middleware output.

func Interpret

func Interpret(dir string, args []string) *Generator

func (*Generator) AddFileHeader

func (g *Generator) AddFileHeader(header string)

func (*Generator) AddModel

func (g *Generator) AddModel(model *ServiceModel)

func (*Generator) Print

func (g *Generator) Print()

func (*Generator) SetupCustomizer

func (g *Generator) SetupCustomizer(customizer string)

type MiddlewareParameter

type MiddlewareParameter struct {
	VariableName string
	TypeName     string
	TypePath     string
	FieldName    string
}

type ServiceModel

type ServiceModel struct {
	TypeName        string
	Middleware      string
	StructPrefix    string
	Interface       []interpreter.DeclaredFunction
	InputParameters []MiddlewareParameter
	StructPtr       string
	ServicePtr      string
}

Jump to

Keyboard shortcuts

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