app

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2021 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssembleTemplate

type AssembleTemplate func(templateDir string, ctx ToMacroReplaceContext) (targetFilePaths []string, err error)

AssembleTemplate is a shortcut implementation of TemplateAssembler based on a function

func (AssembleTemplate) AssembleTemplate

func (g AssembleTemplate) AssembleTemplate(templateDir string, ctx ToMacroReplaceContext,
) (targetFilePaths []string, err error)

AssembleTemplate assembles template from code using replace context.

type GenerateIter

type GenerateIter func(packagePath string, ctx GenerateIterContext) (targetFilePaths []string, err error)

GenerateIter is a shortcut implementation of IterGenerator based on a function

func (GenerateIter) GenerateIter

func (g GenerateIter) GenerateIter(packagePath string, ctx GenerateIterContext) (targetFilePaths []string, err error)

GenerateIter should generate code using path to package and context.

type GenerateIterContext

type GenerateIterContext struct {
	// TypeName sets the name of the target type to generate iterator for.
	TypeName string
	// PackageName sets the package name of the package where
	// the code will be generated.
	PackageName string
	// TitlePrefix sets the prefix of titles in generated iterator types.
	TitlePrefix string
	// ZeroTypeValue sets zero value of the target type.
	ZeroTypeValue string
}

GenerateIterContext is a context for iter generator.

type IterGenerator

type IterGenerator interface {
	// GenerateIter should generate code using path to package and context.
	GenerateIter(packagePath string, ctx GenerateIterContext) (targetFilePaths []string, err error)
}

IterGenerator is a use case.

var NoGenerateIter IterGenerator = GenerateIter(func(_ string, _ GenerateIterContext) ([]string, error) {
	return nil, nil
})

NoGenerateIter is a zero value for IterGenerator. It does nothing.

type TemplateAssembler

type TemplateAssembler interface {
	// AssembleTemplate should assemble template from code using replace context.
	AssembleTemplate(templateDir string, ctx ToMacroReplaceContext) (targetFilePaths []string, err error)
}

TemplateAssembler is a use case.

var NoAssembleTemplate TemplateAssembler = AssembleTemplate(func(_ string, _ ToMacroReplaceContext) ([]string, error) {
	return nil, nil
})

NoAssembleTemplate is a zero value for TemplateAssembler. It does nothing.

type ToMacroReplaceContext

type ToMacroReplaceContext struct {
	// TypeNameFrom is a type name which will be replaced
	// to the type macro. Note: if TypeNameFrom equals to TitlePrefixFrom,
	// so first TitlePrefixFrom replaced, then TypeNameFrom.
	TypeNameFrom string
	// PackageNameFrom is a type name which will be replaced
	// to the package macro.
	PackageNameFrom string
	// TitlePrefixFrom is a type name which will be replaced
	// to the prefix macro. Note: if TypeNameFrom equals to TitlePrefixFrom,
	// so first TitlePrefixFrom replaced, then TypeNameFrom.
	TitlePrefixFrom string
	// ZeroTypeValue is a type name which will be replaced
	// to the zero value type macro.
	ZeroTypeValueFrom string
}

ToMacroReplaceContext is a context for macro replacing.

Directories

Path Synopsis
TODO the logic into go text templates
TODO the logic into go text templates

Jump to

Keyboard shortcuts

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