Documentation
¶
Overview ¶
Package nodeindex derives, from a YAML node tree and the text it was parsed from, the two things the parser does not report: where the block headed by a node ends, and which key an anchor was defined under.
The first half is interim. https://github.com/yaml/go-yaml/pull/391 records end positions on the node, which is where they belong and which they are exact at; this derives them instead, and agrees on 99.98% of blocks.
The import is the yaml fork this module already depends on rather than the stock package, whose Node is the same type: nothing here needs the fork, and the switch to stock yaml belongs to the change that removes the fork.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index answers where the block headed by a key ends.
The parser reports where every node starts and nothing about where it stops, so the end is derived, in two passes over the tree.
measure takes the largest line among a node's descendants. Reading that off the tree rather than from indentation is what makes a sequence item work: a parameter's key location is the item's first key, at the same column as the keys following it, so no column comparison can tell the end of the item from the start of its own second field.
extend then grows that over lines belonging to the block that carry no node, which is the body of a block scalar. Together they agree with a parser's own end positions on 99.98% of blocks across a 4,240-file corpus; measure alone agrees on 99.60%, the difference being blocks that end in a `description: |`.
Trailing blank and comment lines fall outside.
func New ¶
New indexes data's node tree. Ends are derived per file: a $ref into another document is decoded separately, against its own text.