Documentation ¶
Index ¶
- func PrefixDropper(prefix string) dstutil.ApplyFunc
- func PrefixReplacer(prefix, replace string) dstutil.ApplyFunc
- func SlashHeaderMapper(maingen string) codejen.FileMapper
- type Any
- type CoreKindJennyConfig
- type GoTypesJenny
- type ManyToMany
- type ManyToOne
- type OneToMany
- type OneToOne
- type PropertyType
- type PropertyTypes
- type ResourceGoTypesJenny
- type SchemaForGen
- type SubresourceGoTypesJenny
- type TSResourceJenny
- type TSTypesJenny
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 PrefixReplacer ¶
PrefixReplacer 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.
When an exact match for prefix is found, the provided replace string is substituted.
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 Any ¶
type Any struct {
// contains filtered or unexported fields
}
func (*Any) UnmarshalJSON ¶
type CoreKindJennyConfig ¶
type CoreKindJennyConfig struct { // GenDirName returns the name of the directory in which the file should be // generated. Defaults to DefForGen.Lineage().Name() if nil. GenDirName func(kindsys.Kind) string }
CoreKindJennyConfig holds configuration options for CoreKindJenny.
type GoTypesJenny ¶
GoTypesJenny is a OneToOne that produces Go types for the provided thema.Schema.
func (GoTypesJenny) Generate ¶
func (j GoTypesJenny) Generate(sfg SchemaForGen) (*codejen.File, error)
func (GoTypesJenny) JennyName ¶
func (j GoTypesJenny) JennyName() string
type ManyToMany ¶
type ManyToMany codejen.ManyToMany[kindsys.Kind]
type ManyToOne ¶
func BaseCoreRegistryJenny ¶
BaseCoreRegistryJenny generates a static registry for core kinds that only initializes their kindsys.Kind. No slot kinds are composed.
Path should be the relative path to the directory that will contain the generated registry. kindrelroot should be the repo-root-relative path to the parent directory to all directories that contain generated kind bindings (e.g. pkg/kind).
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 ¶
func LatestMajorsOrXJenny ¶
func LatestMajorsOrXJenny(parentdir string, forceGroup bool, inner codejen.OneToOne[SchemaForGen]) OneToMany
LatestMajorsOrXJenny returns a jenny that repeats the input for the latest in each major version.
TODO remove forceGroup option, it's a temporary hack to accommodate core kinds
type OneToOne ¶
func CoreKindJenny ¶
func CoreKindJenny(gokindsdir string, cfg *CoreKindJennyConfig) OneToOne
CoreKindJenny generates the implementation of kindsys.Core for the provided kind declaration.
gokindsdir should be the relative path to the parent directory that contains all generated kinds.
This generator only has output for core structured kinds.
func LatestJenny ¶
func LatestJenny(parentdir string, inner codejen.OneToOne[SchemaForGen]) OneToOne
LatestJenny returns a jenny that runs another jenny for only the latest schema in a DefForGen, and prefixes the resulting file with the provided parentdir (e.g. "pkg/kinds/") and with a directory based on the kind's machine name (e.g. "dashboard/").
type PropertyType ¶
type PropertyType string
const ( PropertyTypeString PropertyType = "string" PropertyTypeNumber PropertyType = "number" PropertyTypeBoolean PropertyType = "boolean" PropertyTypeObject PropertyType = "object" PropertyTypeArray PropertyType = "array" PropertyTypeNull PropertyType = "null" )
type PropertyTypes ¶
type PropertyTypes []PropertyType
func (*PropertyTypes) HasType ¶
func (pts *PropertyTypes) HasType(pt PropertyType) bool
func (*PropertyTypes) UnmarshalJSON ¶
func (pts *PropertyTypes) UnmarshalJSON(data []byte) error
type ResourceGoTypesJenny ¶
func (*ResourceGoTypesJenny) JennyName ¶
func (*ResourceGoTypesJenny) JennyName() string
type SchemaForGen ¶
type SchemaForGen struct { // The PascalCase name of the schematized type. Name string // The schema to be rendered for the type itself. Schema thema.Schema // Whether the schema is grouped. See https://github.com/grafana/thema/issues/62 IsGroup bool }
SchemaForGen is an intermediate values type for jennies that holds both a thema.Schema, and values relevant to generating the schema that should properly, eventually, be in thema itself.
TODO this will be replaced by thema-native constructs
func ForLatestSchema ¶
func ForLatestSchema(k kindsys.Kind) SchemaForGen
ForLatestSchema returns a SchemaForGen for the latest schema in the provided kindsys.Kind's lineage.
TODO this will be replaced by thema-native constructs
type SubresourceGoTypesJenny ¶
func (*SubresourceGoTypesJenny) JennyName ¶
func (*SubresourceGoTypesJenny) JennyName() string
type TSResourceJenny ¶
type TSResourceJenny struct{}
TSResourceJenny is a OneToOne that produces TypeScript types and defaults for a Thema schema.
Thema's generic TS jenny will be able to replace this one once https://github.com/grafana/thema/issues/89 is complete.
func (TSResourceJenny) Generate ¶
func (j TSResourceJenny) Generate(sfg SchemaForGen) (*codejen.File, error)
func (TSResourceJenny) JennyName ¶
func (j TSResourceJenny) JennyName() string
type TSTypesJenny ¶
type TSTypesJenny struct{}
TSTypesJenny is a OneToOne that produces TypeScript types and defaults for a Thema schema.
Thema's generic TS jenny will be able to replace this one once https://github.com/grafana/thema/issues/89 is complete.
func (TSTypesJenny) Generate ¶
func (j TSTypesJenny) Generate(sfg SchemaForGen) (*codejen.File, error)
func (TSTypesJenny) JennyName ¶
func (j TSTypesJenny) JennyName() string