Documentation
¶
Index ¶
- func ConvertImport(im *ast.ImportSpec) (tsast.ImportSpec, error)
- func MapCUEImportToTS(path string) (string, error)
- func PermittedCUEImports() []string
- func PrefixDropper(prefix string) dstutil.ApplyFunc
- func SlashHeaderMapper(maingen string) codejen.FileMapper
- type ApplyFunc
- type CoreRegistryJenny
- type GoSpecJenny
- type K8ResourcesJenny
- type ManyToMany
- type ManyToOne
- type OneToMany
- type OneToOne
- type Schema
- type SchemaForGen
- type TSTypesJenny
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
LatestMajorsOrXJenny returns a jenny that repeats the input for the latest in each major version.
type OneToOne ¶
type OneToOne codejen.OneToOne[SchemaForGen]
type Schema ¶
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 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