Documentation
¶
Index ¶
- type Branch
- type Document
- func (d *Document) AddChild(parent NodeID, text string) (NodeID, bool)
- func (d *Document) AddSiblingAfter(id NodeID, text string) (NodeID, bool)
- func (d *Document) AppendChild(parent NodeID, text string) (NodeID, error)
- func (d *Document) AppendRoot(text string) NodeID
- func (d *Document) Children(id NodeID) []NodeID
- func (d *Document) Clone() *Document
- func (d *Document) CopyBranch(id NodeID) (Branch, bool)
- func (d *Document) Delete(id NodeID) bool
- func (d *Document) Demote(id NodeID) bool
- func (d *Document) Len() int
- func (d *Document) MoveSibling(id NodeID, delta int) bool
- func (d *Document) Node(id NodeID) (Node, bool)
- func (d *Document) Parent(id NodeID) NodeID
- func (d *Document) PasteChild(parent NodeID, branch Branch) (NodeID, bool)
- func (d *Document) PasteSibling(id NodeID, branch Branch) (NodeID, bool)
- func (d *Document) Promote(id NodeID) bool
- func (d *Document) Rename(id NodeID, text string) bool
- func (d *Document) Roots() []NodeID
- func (d *Document) Text(id NodeID) string
- func (d *Document) Validate() error
- type Node
- type NodeID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document stores an ordered forest. Most maps contain one root, but accepting a forest lets Beech open indentation-based files without changing them.
func NewEmpty ¶
func NewEmpty() *Document
NewEmpty creates a document without roots. It is intended for parsers.
func (*Document) AddSiblingAfter ¶
AddSiblingAfter adds a node immediately after id.
func (*Document) AppendChild ¶
AppendChild adds a child to parent.
func (*Document) AppendRoot ¶
AppendRoot adds a root at the end of the forest.
func (*Document) CopyBranch ¶
CopyBranch returns a detached copy of id and its descendants.
func (*Document) Delete ¶
Delete removes a node and all descendants. The final root cannot be removed.
func (*Document) MoveSibling ¶
MoveSibling moves a node by delta positions among its siblings.
func (*Document) PasteChild ¶
PasteChild clones branch as the last child of parent.
func (*Document) PasteSibling ¶
PasteSibling clones branch immediately after id.