codegen

package
v11.1.4-modfix Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertImport

func ConvertImport(im *ast.ImportSpec) (tsast.ImportSpec, error)

ConvertImport converts a CUE import statement, represented in its AST form, to the corresponding TS import, if the CUE import is allowed.

Some CUE imports are allowed but have no corresponding TS import - the CUE types from that package are expected to be inlined.

func MapCUEImportToTS

func MapCUEImportToTS(path string) (string, error)

MapCUEImportToTS maps the provided CUE import path to the corresponding TypeScript import path in generated code.

Providing an import path that is not allowed results in an error. If a nil error and empty string are returned, the import path should be dropped in generated code.

func PermittedCUEImports

func PermittedCUEImports() []string

PermittedCUEImports returns the list of import paths that may be imported in Grafana kind definitions.

func PrefixDropper

func PrefixDropper(prefix string) dstutil.ApplyFunc

PrefixDropper returns a dstutil.ApplyFunc that removes the provided prefix string when it appears as a leading sequence in type names, var names, and comments in a generated Go file.

func SlashHeaderMapper

func SlashHeaderMapper(maingen string) codejen.FileMapper

SlashHeaderMapper produces a FileMapper that injects a comment header onto a codejen.File indicating the main generator that produced it (via the provided maingen, which should be a path) and the jenny or jennies that constructed the file.

Types

type ApplyFunc

type ApplyFunc func(sfg SchemaForGen, file *ast.File)

type CoreRegistryJenny

type CoreRegistryJenny struct {
}

CoreRegistryJenny generates a registry with all core kinds.

func (*CoreRegistryJenny) Generate

func (jenny *CoreRegistryJenny) Generate(cueFiles ...SchemaForGen) (codejen.Files, error)

func (*CoreRegistryJenny) JennyName

func (jenny *CoreRegistryJenny) JennyName() string

type GoSpecJenny

type GoSpecJenny struct {
	ApplyFuncs []dstutil.ApplyFunc
}

func (*GoSpecJenny) Generate

func (jenny *GoSpecJenny) Generate(sfg ...SchemaForGen) (codejen.Files, error)

func (*GoSpecJenny) JennyName

func (jenny *GoSpecJenny) JennyName() string

type K8ResourcesJenny

type K8ResourcesJenny struct {
}

K8ResourcesJenny generates resource, metadata and status for each file.

func (*K8ResourcesJenny) Generate

func (jenny *K8ResourcesJenny) Generate(cueFiles ...SchemaForGen) (codejen.Files, error)

func (*K8ResourcesJenny) JennyName

func (jenny *K8ResourcesJenny) JennyName() string

type ManyToMany

type ManyToMany codejen.ManyToMany[SchemaForGen]

type ManyToOne

type ManyToOne codejen.ManyToOne[SchemaForGen]

func TSVeneerIndexJenny

func TSVeneerIndexJenny(dir string) ManyToOne

TSVeneerIndexJenny generates an index.gen.ts file with references to all generated TS types. Elements with the attribute @grafana(TSVeneer="type") are exported from a handwritten file, rather than the raw generated types.

The provided dir is the path, relative to the grafana root, to the directory that should contain the generated index.

Implicitly depends on output patterns in TSTypesJenny. TODO this is wasteful; share-nothing generator model entails re-running the cuetsy gen that TSTypesJenny already did

type OneToMany

type OneToMany codejen.OneToMany[SchemaForGen]

func LatestMajorsOrXJenny

func LatestMajorsOrXJenny(parentdir string) OneToMany

LatestMajorsOrXJenny returns a jenny that repeats the input for the latest in each major version.

type OneToOne

type OneToOne codejen.OneToOne[SchemaForGen]

type Schema

type Schema struct {
	Name     string
	FilePath string
}

The following group of types, beginning with tvars_*, all contain the set of variables expected by the corresponding named template file under tmpl/

type SchemaForGen

type SchemaForGen struct {
	Name       string
	CueFile    cue.Value
	FilePath   string
	IsGroup    bool
	OutputName string // Some TS output files are capitalised and others not.
}

type TSTypesJenny

type TSTypesJenny struct {
	ApplyFuncs []ApplyFunc
}

TSTypesJenny is a OneToOne that produces TypeScript types and defaults.

func (TSTypesJenny) Generate

func (j TSTypesJenny) Generate(sfg SchemaForGen) (*codejen.File, error)

func (TSTypesJenny) JennyName

func (j TSTypesJenny) JennyName() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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