Documentation
¶
Index ¶
- Constants
- func FormatCue(val cue.Value, opts []cue.Option, pkg string) ([]byte, error)
- func FormatJson(val cue.Value, escape bool) ([]byte, error)
- func FormatToml(val cue.Value) ([]byte, error)
- func FormatXml(val cue.Value) ([]byte, error)
- func FormatYaml(val cue.Value) ([]byte, error)
- type File
- func (F *File) FormatData(val cue.Value, format string) ([]byte, error)
- func (F *File) FormatRendered() (err error)
- func (F *File) MergeIn(other map[string]any)
- func (F *File) ReadUser(outdir string) error
- func (F *File) Render(outdir string, UseDiff3, NoFmt bool) error
- func (F *File) RenderData() (err error)
- func (F *File) RenderTemplate(nofmt bool) (err error)
- func (F *File) UnifyContent(UseDiff3 bool) (write bool, err error)
- func (F *File) WriteOutput(basedir string) error
- func (F *File) WriteShadow(basedir string) error
- type FileStats
- type FmtConfig
- type Generator
- func (G *Generator) CleanupRemainingShadow(outputDir, shadowDir string, verbosity int, keepDeleted bool) (errs []error)
- func (G *Generator) CleanupShadow(outputBase, shadowBase string, verbosity int, keepDeleted bool) (errs []error)
- func (G *Generator) DecodeFromCUE(root cue.Value) (errs []error)
- func (G *Generator) GenerateFiles(outdir string) []error
- func (G *Generator) Initialize() []error
- func (G *Generator) LoadShadow(basedir string) error
- func (G *Generator) NamePath() string
- func (G *Generator) OutputPath() string
- func (G *Generator) PrintInfo()
- func (G *Generator) ResolveFile(F *File) error
- func (G *Generator) RunPostFlow() error
- func (G *Generator) RunPreFlow() error
- func (G *Generator) ShadowPath() string
- func (G *Generator) Write(outputBase, shadowBase string) (errs []error)
- type GeneratorStats
- type StaticGlobs
- type TemplateContent
- type TemplateGlobs
Constants ¶
View Source
const CUE_VENDOR_DIR = "cue.mod/pkg"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type File ¶
type File struct {
// Input Data, local to this file
// this can sometimes be a list for Adhoc
In any
// The full path under the output location
// empty implies don't generate, even though it may endup in the list
Filepath string
// Template parameters (only one should be set at a time i.e. != "")
TemplateContent string // The content, takes precedence over next option
TemplatePath string // Named template
DatafileFormat string // Data format file
StaticFile bool
// Formatting
FormattingDisabled bool
FormattingConfig *FmtConfig
// Template delimiters
TemplateDelims templates.Delims
// CUE settings
Package string
Raw bool
Final bool
Concrete bool
Definitions bool
Optional bool
Hidden bool
Attributes bool
Docs bool
InlineImports bool
ErrorsAsValues bool
// CUE value for datafiles
// (we use a different name here so that it does not automatically try to decode, which would require concreteness)
Value cue.Value
// Template Instance Pointer
// If local, this will be created when the template content is loaded
// If a named template, actual template lives in the generator and is created at folder import time
TemplateInstance *templates.Template
// Content
RenderContent []byte
FinalContent []byte
// Shadow related
ShadowFile *File
UserFile *File
DoWrite bool
// Bookkeeping
Errors []error
FileStats
// contains filtered or unexported fields
}
func (*File) FormatData ¶ added in v0.6.9
func (*File) FormatRendered ¶
func (*File) RenderData ¶ added in v0.6.1
func (*File) RenderTemplate ¶
func (*File) WriteOutput ¶
func (*File) WriteShadow ¶
type FileStats ¶
type FileStats struct {
// using 0 (false) and 1 (true) for easier summation code below
IsNew int
IsSame int
IsSkipped int
IsWritten int
IsErr int
IsModified int
IsModifiedRender int
IsModifiedOutput int
IsModifiedDiff3 int
IsConflicted int
RenderingTime time.Duration
CompareTime time.Duration
TotalTime time.Duration
}
type Generator ¶
type Generator struct {
*hof.Node[Generator]
//
// Set by Hof via cuelang extraction
// Label in Cuelang
Name string
// Base directory for output
Outdir string
// Other important dirs when loading templates (auto set)
CueModuleRoot string
RootModuleName string
WorkingDir string
CwdToRoot string // module root <- working dir (../..)
// "Global" input, merged with out replacing onto the files
In map[string]any
Val cue.Value
// File globs to watch and trigger regen on change
WatchFull []string
WatchFast []string
// Formatting
FormattingDisabled bool
FormatData bool
FormattingConfigs map[string]FmtConfig
// The list fo files for hof to generate, in cue values
Out []*File
Templates []*TemplateGlobs
Partials []*TemplateGlobs
// Filepath globs for static files to load
Statics []*StaticGlobs
// The following will be automatically added to the template context
// under its name for reference in GenFiles and partials in templates
EmbeddedTemplates map[string]*TemplateContent
EmbeddedPartials map[string]*TemplateContent
// Static files are available for pure cue generators that want to have static files
// These should be named by their filepath, but be the content of the file
EmbeddedStatics map[string]string
// Subgenerators for composition
Generators map[string]*Generator
// Used for indexing into the vendor directory...
// This should be `ModuleName: string | *"github.com/..." in your generator
// and set to "" if you use the generator from within the module itself
ModuleName string
// Use Diff3 & Shadow
Diff3FlagSet bool // set by flag
UseDiff3 bool
NoFormat bool
// enable pre/post-flows
ExecFlows bool
// Disabled? we do this when looking at expressions and optimizing
// TODO, make this field available in cuelang?
Disabled bool
// Template System Cache
TemplateMap templates.TemplateMap
PartialsMap templates.TemplateMap
// Files and the shadow dir for doing neat things
OrderedFiles []*File
Files map[string]*File
Shadow map[string]*File
// Print extra information
Debug bool
Verbosity int
// Status for this generator and processing
Stats *GeneratorStats
// Cuelang related, also set externally
CueValue cue.Value
// contains filtered or unexported fields
}
A generator pulled from the cue instances
func (*Generator) CleanupRemainingShadow ¶ added in v0.6.5
func (*Generator) CleanupShadow ¶ added in v0.6.8
func (*Generator) DecodeFromCUE ¶ added in v0.6.5
func (*Generator) GenerateFiles ¶
func (*Generator) Initialize ¶ added in v0.2.9
func (*Generator) LoadShadow ¶ added in v0.6.7
func (*Generator) NamePath ¶ added in v0.6.5
Returns Generators name path, including parents as a path like string
func (*Generator) OutputPath ¶ added in v0.6.5
Returns Generators contribution to the output path, including parents contributions if a subgen. Each gen in the path is [parent]/G.Outdir
func (*Generator) ResolveFile ¶ added in v0.2.9
func (*Generator) RunPostFlow ¶ added in v0.6.9
func (*Generator) RunPreFlow ¶ added in v0.6.9
func (*Generator) ShadowPath ¶ added in v0.6.5
Returns Generators contribution to the shadow path, including parents contributions if a subgen. Each gen in the path is [parent]/G.Name/G.Outdir
type GeneratorStats ¶
type GeneratorStats struct {
NumNew int
NumSame int
NumSkipped int
NumDeleted int
NumWritten int
NumStatic int
NumErr int
TotalFiles int
NumModified int
NumModifiedRender int
NumModifiedOutput int
NumModifiedDiff3 int
NumConflicted int
LoadingTime time.Duration
RenderingTime time.Duration
WritingTime time.Duration
TotalTime time.Duration
}
func (*GeneratorStats) CalcTotals ¶
func (S *GeneratorStats) CalcTotals(G *Generator) error
func (*GeneratorStats) String ¶
func (S *GeneratorStats) String() string
type StaticGlobs ¶ added in v0.6.0
type TemplateContent ¶ added in v0.6.0
Source Files
¶
Click to show internal directories.
Click to hide internal directories.