Documentation
¶
Index ¶
- type DoTransform
- type Target
- type TargetCollection
- func (c *TargetCollection) FilenameToTarget(filename string) (longestTarget *Target, longestExt string)
- func (c *TargetCollection) Transform(data *TargetData, transformationNames []string) (end *TargetData, results core.ResultList)
- func (c *TargetCollection) TransformationNames() []string
- func (c *TargetCollection) Traverse(start *Target, transformationNames []string) (transformations []*Transformation, end *Target, results core.ResultList)
- type TargetData
- type Transformation
- type TransformationCollection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DoTransform ¶
type DoTransform func(*TargetData) (*TargetData, core.ResultList)
type Target ¶
type Target struct {
// The name(s) of the target.
// The convention is to use lowercase letters, with '-' as a separator, if
// required.
// The first name in the list is the default name, which is used and
// displayed in the CLI. Other names in the list are valid names when the
// user inputs them. At least one name must be provided.
Names []string
// A short description of the target.
// This is used to enhance the user experience in the CLI, and possibly,
// in other places.
Description string
// The list of file extensions (suffixes) that represent this target.
// The first extension in the list is the default extension, which is
// used as the default extension for output (generated) files.
// At least one extension must be provided.
// Other extensions in the list are used to automatically detect the target
// type from the input file name.
Extensions []string
// An optional generation context for this target.
// This is used to parse and generate the target code from a USM source.
// If nil, assumes that the target cannot be generated from a USM source.
GenerationContext *gen.GenerationContext
Transformations TransformationCollection
}
type TargetCollection ¶
type TargetCollection struct {
Targets []*Target
NameToTarget faststringmap.Map[*Target]
}
func NewTargetCollection ¶
func NewTargetCollection( targets ...*Target, ) *TargetCollection
func (*TargetCollection) FilenameToTarget ¶
func (c *TargetCollection) FilenameToTarget( filename string, ) (longestTarget *Target, longestExt string)
Infer the target from the filename extension. Returns nil if no matching target is found. If multiple targets match the filename, the one that matches with the longest prefix is returned.
func (*TargetCollection) Transform ¶
func (c *TargetCollection) Transform( data *TargetData, transformationNames []string, ) (end *TargetData, results core.ResultList)
func (*TargetCollection) TransformationNames ¶
func (c *TargetCollection) TransformationNames() []string
func (*TargetCollection) Traverse ¶
func (c *TargetCollection) Traverse( start *Target, transformationNames []string, ) ( transformations []*Transformation, end *Target, results core.ResultList, )
Traverse the target collection according to the provided transformation names. This does not actually perform the transformations, but checks for the legality of the transformation chain.
type TargetData ¶
type TargetData struct {
// A target instance that describes current target type.
*Target
// A representation of the target data as code.
// If nil, an artifact representation is used instead, and must be provided.
Code *gen.FileInfo
// A representation of the target data as a binary artifact.
// If not nil, this is the preferred representation of the target data,
// and the code representation is ignored.
Artifact *bytes.Buffer
}
func NewTargetData ¶
func NewTargetData(target *Target, code *gen.FileInfo) *TargetData
type Transformation ¶
type Transformation struct {
Names []string
Description string
// The name of the target of this transformation.
TargetName string
Transform DoTransform
}
type TransformationCollection ¶
type TransformationCollection struct {
Transformations []*Transformation
NameToTransformation faststringmap.Map[*Transformation]
}
func NewTransformationCollection ¶
func NewTransformationCollection(transformations ...*Transformation) *TransformationCollection
func (*TransformationCollection) Names ¶
func (c *TransformationCollection) Names() []string
Click to show internal directories.
Click to hide internal directories.