Documentation
¶
Overview ¶
Package bkl implements a layered configuration language parser.
- Language & tool documentation: https://bkl.gopatchy.io/
- Go library source: https://github.com/gopatchy/bkl
- Go library documentation: https://pkg.go.dev/github.com/gopatchy/bkl
Index ¶
- func CountKeywordMatches(text string, keywords []string) int
- func Diff(fx fs.FS, srcPath, dstPath string, rootPath string, workingDir string, ...) ([]byte, error)
- func Evaluate(fx fs.FS, files []string, rootPath string, workingDir string, ...) ([]byte, error)
- func FormatOutput(data any, format *string, paths ...*string) ([]byte, error)
- func GetAllTests() (map[string]*DocExample, error)
- func GetTests() (map[string]*DocExample, error)
- func Intersect(fx fs.FS, paths []string, rootPath string, workingDir string, ...) ([]byte, error)
- func Required(fx fs.FS, path string, rootPath string, workingDir string, format *string, ...) ([]byte, error)
- type CompareResult
- type DocCompare
- type DocConvert
- type DocDiff
- type DocEvaluate
- type DocExample
- type DocFixit
- type DocIntersect
- type DocItem
- type DocLayer
- type DocRequired
- type DocSection
- type DocSideBySide
- type TreeResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountKeywordMatches ¶ added in v1.0.53
func Evaluate ¶ added in v1.0.52
func Evaluate(fx fs.FS, files []string, rootPath string, workingDir string, env map[string]string, format *string, sort []string, paths ...*string) ([]byte, error)
Evaluate processes the specified files and returns the formatted output. If format is nil, it infers the format from the paths parameter (output path first, then input files). If env is nil, it uses the current OS environment.
func FormatOutput ¶ added in v1.0.52
FormatOutput marshals the given data to the specified format. If format is nil or points to an empty string, it looks at the provided paths and uses the file extension of the first non-nil path as the format. Returns the marshaled bytes or an error if the format is unknown or marshaling fails.
func GetAllTests ¶ added in v1.0.53
func GetAllTests() (map[string]*DocExample, error)
func GetTests ¶ added in v1.0.52
func GetTests() (map[string]*DocExample, error)
func Required ¶ added in v1.0.52
func Required(fx fs.FS, path string, rootPath string, workingDir string, format *string, paths ...*string) ([]byte, error)
Required loads a file and returns only the required fields and their ancestors. It processes all documents in the file, outputting one document for each input document. The file is loaded directly without processing, matching bklr behavior. If format is nil, it infers the format from the paths parameter.
Types ¶
type CompareResult ¶ added in v1.0.52
type DocCompare ¶ added in v1.0.53
type DocCompare struct {
Left DocLayer `yaml:"left" json:"left" toml:"left"`
Right DocLayer `yaml:"right" json:"right" toml:"right"`
Result DocLayer `yaml:"result" json:"result" toml:"result"`
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty" toml:"env,omitempty"`
Sort []string `yaml:"sort,omitempty" json:"sort,omitempty" toml:"sort,omitempty"`
}
func (*DocCompare) ConvertCodeBlocks ¶ added in v1.0.53
func (dc *DocCompare) ConvertCodeBlocks(targetFormat string) bool
func (*DocCompare) Score ¶ added in v1.0.53
func (dc *DocCompare) Score(keywords []string) int
type DocConvert ¶ added in v1.0.53
type DocConvert struct {
From DocLayer `yaml:"from" json:"from"`
To DocLayer `yaml:"to" json:"to"`
}
func (*DocConvert) ConvertCodeBlocks ¶ added in v1.0.53
func (dc *DocConvert) ConvertCodeBlocks(targetFormat string) bool
func (*DocConvert) Score ¶ added in v1.0.53
func (dc *DocConvert) Score(keywords []string) int
type DocDiff ¶ added in v1.0.53
type DocDiff struct {
Base DocLayer `yaml:"base" json:"base" toml:"base"`
Target DocLayer `yaml:"target" json:"target" toml:"target"`
Result DocLayer `yaml:"result" json:"result" toml:"result"`
Selector []string `yaml:"selector,omitempty" json:"selector,omitempty" toml:"selector,omitempty"`
Errors []string `yaml:"errors,omitempty" json:"errors,omitempty" toml:"errors,omitempty"`
}
func (*DocDiff) ConvertCodeBlocks ¶ added in v1.0.53
type DocEvaluate ¶ added in v1.0.53
type DocEvaluate struct {
Inputs []*DocLayer `yaml:"inputs" json:"inputs" toml:"inputs"`
Result DocLayer `yaml:"result" json:"result" toml:"result"`
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty" toml:"env,omitempty"`
Errors []string `yaml:"errors,omitempty" json:"errors,omitempty" toml:"errors,omitempty"`
Root string `yaml:"root,omitempty" json:"root,omitempty" toml:"root,omitempty"`
Sort []string `yaml:"sort,omitempty" json:"sort,omitempty" toml:"sort,omitempty"`
}
func (*DocEvaluate) ConvertCodeBlocks ¶ added in v1.0.53
func (de *DocEvaluate) ConvertCodeBlocks(targetFormat string) bool
func (*DocEvaluate) Score ¶ added in v1.0.53
func (de *DocEvaluate) Score(keywords []string) int
type DocExample ¶ added in v1.0.52
type DocExample struct {
Description string `toml:"description" json:"description" yaml:"description,omitempty"`
Evaluate *DocEvaluate `yaml:"evaluate,omitempty" json:"evaluate,omitempty" toml:"evaluate,omitempty"`
Diff *DocDiff `yaml:"diff,omitempty" json:"diff,omitempty" toml:"diff,omitempty"`
Intersect *DocIntersect `yaml:"intersect,omitempty" json:"intersect,omitempty" toml:"intersect,omitempty"`
Required *DocRequired `yaml:"required,omitempty" json:"required,omitempty" toml:"required,omitempty"`
Convert *DocConvert `yaml:"convert,omitempty" json:"convert,omitempty" toml:"convert,omitempty"`
Fixit *DocFixit `yaml:"fixit,omitempty" json:"fixit,omitempty" toml:"fixit,omitempty"`
Compare *DocCompare `yaml:"compare,omitempty" json:"compare,omitempty" toml:"compare,omitempty"`
Benchmark bool `toml:"benchmark,omitempty" json:"benchmark,omitempty" yaml:"benchmark,omitempty"`
}
func (*DocExample) ConvertCodeBlocks ¶ added in v1.0.53
func (de *DocExample) ConvertCodeBlocks(targetFormat string) bool
func (*DocExample) Score ¶ added in v1.0.53
func (de *DocExample) Score(keywords []string) int
type DocFixit ¶ added in v1.0.53
type DocFixit struct {
Original DocLayer `yaml:"original,omitempty" json:"original,omitempty"`
Bad DocLayer `yaml:"bad" json:"bad"`
Good DocLayer `yaml:"good" json:"good"`
}
func (*DocFixit) ConvertCodeBlocks ¶ added in v1.0.53
type DocIntersect ¶ added in v1.0.53
type DocIntersect struct {
Inputs []*DocLayer `yaml:"inputs" json:"inputs" toml:"inputs"`
Result DocLayer `yaml:"result" json:"result" toml:"result"`
Selector []string `yaml:"selector,omitempty" json:"selector,omitempty" toml:"selector,omitempty"`
Errors []string `yaml:"errors,omitempty" json:"errors,omitempty" toml:"errors,omitempty"`
}
func (*DocIntersect) ConvertCodeBlocks ¶ added in v1.0.53
func (di *DocIntersect) ConvertCodeBlocks(targetFormat string) bool
func (*DocIntersect) Score ¶ added in v1.0.53
func (di *DocIntersect) Score(keywords []string) int
type DocItem ¶ added in v1.0.52
type DocItem struct {
Content string `yaml:"content,omitempty" json:"content,omitempty"`
Example *DocExample `yaml:"example,omitempty" json:"example,omitempty"`
Code *DocLayer `yaml:"code,omitempty" json:"code,omitempty"`
SideBySide *DocSideBySide `yaml:"side_by_side,omitempty" json:"side_by_side,omitempty"`
}
type DocLayer ¶ added in v1.0.52
type DocLayer struct {
Label string `yaml:"label,omitempty" json:"label,omitempty" toml:"label,omitempty"`
Filename string `yaml:"filename,omitempty" json:"filename,omitempty" toml:"filename,omitempty"`
Code string `yaml:"code" json:"code" toml:"code"`
Content string `yaml:"content,omitempty" json:"content,omitempty" toml:"content,omitempty"`
Highlights []string `yaml:"highlights,omitempty" json:"highlights,omitempty" toml:"highlights,omitempty"`
Languages [][]any `yaml:"languages,omitempty" json:"languages,omitempty" toml:"languages,omitempty"`
Expandable bool `yaml:"expandable,omitempty" json:"expandable,omitempty" toml:"expandable,omitempty"`
Collapsed bool `yaml:"collapsed,omitempty" json:"collapsed,omitempty" toml:"collapsed,omitempty"`
}
func (*DocLayer) ConvertCodeBlocks ¶ added in v1.0.53
type DocRequired ¶ added in v1.0.53
type DocRequired struct {
Inputs []*DocLayer `yaml:"inputs" json:"inputs" toml:"inputs"`
Result DocLayer `yaml:"result" json:"result" toml:"result"`
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty" toml:"env,omitempty"`
Errors []string `yaml:"errors,omitempty" json:"errors,omitempty" toml:"errors,omitempty"`
Root string `yaml:"root,omitempty" json:"root,omitempty" toml:"root,omitempty"`
}
func (*DocRequired) ConvertCodeBlocks ¶ added in v1.0.53
func (dr *DocRequired) ConvertCodeBlocks(targetFormat string) bool
func (*DocRequired) Score ¶ added in v1.0.53
func (dr *DocRequired) Score(keywords []string) int
type DocSection ¶ added in v1.0.52
type DocSection struct {
ID string `yaml:"id" json:"id"`
Title string `yaml:"title" json:"title"`
Items []DocItem `yaml:"items" json:"items"`
Source string `yaml:"-" json:"-"`
}
func GetDocSections ¶ added in v1.0.52
func GetDocSections() ([]DocSection, error)
func (*DocSection) ConvertCodeBlocks ¶ added in v1.0.53
func (ds *DocSection) ConvertCodeBlocks(targetFormat string) bool
func (*DocSection) Score ¶ added in v1.0.53
func (ds *DocSection) Score(keywords []string) int
type DocSideBySide ¶ added in v1.0.52
type DocSideBySide struct {
Left DocLayer `yaml:"left" json:"left"`
Right DocLayer `yaml:"right" json:"right"`
}
func (*DocSideBySide) Score ¶ added in v1.0.53
func (ds *DocSideBySide) Score(keywords []string) int