Documentation
¶
Overview ¶
Package codemod provides source-preserving edits to the authored AW AST used by workflow linters. Transformations never operate on compiled defaults.
Index ¶
- func Apply(content string, transform func(*Frontmatter) error) (string, bool, error)
- type Frontmatter
- func (f *Frontmatter) Comment(path []string, text string) error
- func (f *Frontmatter) Edit(transform func(*aw.Document) error) error
- func (f *Frontmatter) Lookup(path ...string) (any, bool)
- func (f *Frontmatter) MergeSequence(path, destination []string) error
- func (f *Frontmatter) Move(path, destination []string) error
- func (f *Frontmatter) PruneEmpty(path ...string) error
- func (f *Frontmatter) Remove(path ...string) error
- func (f *Frontmatter) Rename(path []string, newKey string) error
- func (f *Frontmatter) RewriteText(transform func(string) string) error
- func (f *Frontmatter) Set(path []string, value any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Frontmatter ¶
Frontmatter keeps the authored document and its source in sync after each edit. Read configuration through Document; mutate it through Edit or the path helpers.
func (*Frontmatter) Comment ¶
func (f *Frontmatter) Comment(path []string, text string) error
Comment appends a single-line annotation to a mapping field without replacing existing comments or changing the document's configuration.
func (*Frontmatter) Edit ¶
func (f *Frontmatter) Edit(transform func(*aw.Document) error) error
Edit applies arbitrary semantic edits to an independent AW document, retaining unchanged YAML nodes through the Actions source merger and preserving the body.
func (*Frontmatter) Lookup ¶
func (f *Frontmatter) Lookup(path ...string) (any, bool)
Lookup resolves an exact mapping path, distinguishing absent fields from null.
func (*Frontmatter) MergeSequence ¶
func (f *Frontmatter) MergeSequence(path, destination []string) error
MergeSequence appends unique source entries to a destination sequence, retaining authored entry comments when both sequences use block syntax.
func (*Frontmatter) Move ¶
func (f *Frontmatter) Move(path, destination []string) error
Move relocates a field without flattening nested values or losing its source spelling. Existing destinations are never overwritten.
func (*Frontmatter) PruneEmpty ¶
func (f *Frontmatter) PruneEmpty(path ...string) error
PruneEmpty removes an empty mapping only when it has no authored comments.
func (*Frontmatter) Remove ¶
func (f *Frontmatter) Remove(path ...string) error
Remove deletes exactly one field. Empty parents are retained by default.
func (*Frontmatter) Rename ¶
func (f *Frontmatter) Rename(path []string, newKey string) error
Rename changes only the key token, including in flow mappings and quoted keys. An existing destination is authoritative, including an explicit null value.
func (*Frontmatter) RewriteText ¶
func (f *Frontmatter) RewriteText(transform func(string) string) error
RewriteText supports lexical migrations that intentionally include YAML comments. AW source boundaries keep the Markdown body outside the transform.