Documentation ¶
Overview ¶
The drill package contains primitives for implementing tree structures that can be drilled into.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Index ¶
Index returns i such that, if it is less than 0, it wraps around to len, so that -1 returns the index of the last node, and so on. Returns a value less than 0 if i is out of bounds, or if len is less than or equal to 0.
Index may be used to implement the i parameter of OrderedBranch.OrderedChild.
Types ¶
type Node ¶
type Node interface { // Fragment returns the data represented by the node. Returns an empty // string if the node has no data, or an error occurs. Fragment() string }
Node is implemented by any type that can produce a fragment.
func Descend ¶
Descend recursively descends into the unordered child nodes matching each given name. Returns nil if a child could not be found at any point.
If a node implements Descender, then the Descend method is called with the remaining names.
func Descendants ¶
Descendants returns a list of all the descendants of the node. If a node does not implement OrderedBranch, then its children are skipped.
func Query ¶
Query recursively descends into the child nodes that match the given queries. A query is either a string or an int. If an int, and the current node is an OrderedBranch, then the next node is acquired using the OrderedChild method of the current node. If a string, and the current node is an UnorderedBranch, then the next node is acquired using the UnorderedChild method of the current node. Returns nil if a child could not be found at any point.
If a node implements Queryer, then the Query method is called with the remaining queries.
type OrderedBranch ¶
type OrderedBranch interface { Node // Len returns the number of ordered child nodes. Should not return a value // less than 0. Len() int // OrderedChild returns the child node at index i. i should be expected to // have the same boundary rules as implemented by the Index function. // Returns nil if i is out of bounds, or Len returns 0. OrderedChild(i int) Node // OrderedChildren returns a retainable list of ordered child nodes. OrderedChildren() []Node }
OrderedBranch extends Node by containing ordered child nodes.
type ReaderNode ¶
type ReaderNode interface { Node FragmentReader() (r io.ReadCloser, err error) }
ReaderNode extends a Node by producing a fragment as a reader.
type UnorderedBranch ¶
type UnorderedBranch interface { Node // UnorderedChild returns the child of the node that matches name. Returns // nil if the child could not be found. UnorderedChild(name string) Node // UnorderedChildren returns a retainable map of names to child nodes. UnorderedChildren() map[string]Node }
UnorderedBranch extends Node by containing unordered child nodes.
Directories ¶
Path | Synopsis |
---|---|
The filesys package implements drill.Node for the io/fs package.
|
The filesys package implements drill.Node for the io/fs package. |
markdown
The markdown package implements filesys.Handler for the Markdown format.
|
The markdown package implements filesys.Handler for the Markdown format. |