gen

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const CmdPrefix = "genpls:"

Variables

This section is empty.

Functions

func IterateFiles

func IterateFiles(pls []Please) iter.Seq2[string, []Please]

IterateFiles returns iterator of grouped commands by the filename.

Types

type Command

type Command struct {
	Name string
	Args []string
	Gen  Func
}

type File

type File struct {
	// Name is an absolute file path.
	Name string
	// Data is a file content.
	Data []byte
}

File is a result of the code generation.

type Func

type Func func(ctx context.Context, name GeneratorName, pls []Please) ([]File, error)

type FuncSpec

type FuncSpec struct {
	Doc  *ast.CommentGroup
	Decl *ast.FuncDecl
	Type *ast.FuncType
}

type GeneratorName

type GeneratorName string

func (GeneratorName) Command

func (gn GeneratorName) Command() string

type PkgName

type PkgName string

type PkgPath

type PkgPath string

type Please

type Please struct {
	Filename string
	Args     []string
	TS       *TypeSpec
	Imports  map[PkgPath]PkgName
}

func (*Please) FormatDoNotEditHeader

func (pls *Please) FormatDoNotEditHeader(name GeneratorName) string

FormatDoNotEditHeader formats DO NOT EDIT header comment.

func (*Please) FormatFileName

func (pls *Please) FormatFileName(name GeneratorName) (filename string)

FormatFileName formats absolute path for a new destination file.

func (*Please) FormatGeneratorFileName

func (pls *Please) FormatGeneratorFileName(name GeneratorName, test bool) (filename string)

FmtFileName formats absolute path for a new destination file.

func (*Please) FormatPkg

func (pls *Please) FormatPkg() string

FmtPkg formats package name declaration.

type TypeSpec

type TypeSpec struct {
	Pkg     *packages.Package
	Doc     *ast.CommentGroup
	Spec    *ast.TypeSpec
	Methods []FuncSpec
}

func (*TypeSpec) AddCMD

func (ts *TypeSpec) AddCMD(cmds map[string][]Please, imports map[PkgPath]PkgName, cmdSeq iter.Seq[Command])

Jump to

Keyboard shortcuts

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