Documentation
¶
Index ¶
- type Node
- func (n *Node) Ancestors() []*Node
- func (n *Node) Append(c *Node)
- func (n *Node) Depth() int
- func (n *Node) HasChild() bool
- func (n *Node) IsLast() bool
- func (n *Node) IsLeaf() bool
- func (n *Node) IsRoot() bool
- func (n *Node) Parent() *Node
- func (n *Node) Render(w io.Writer, o *RenderOptions)
- func (n *Node) ReversedAncestors() []*Node
- type RenderOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct {
Label string `json:"label" yaml:"label"`
Children []*Node `json:"children,omitempty" yaml:"children,omitempty"`
// contains filtered or unexported fields
}
Node is used to represent a tree/branch/leaf
func TreeFromDir ¶
TreeFromDir generates a tree representing given directory structure
func (*Node) Ancestors ¶
Ancestors returns all node's ancestors, from the nearest to the farthest
func (*Node) Render ¶
func (n *Node) Render(w io.Writer, o *RenderOptions)
Render renders a pretty tree structure to given io.Writer
type RenderOptions ¶
type RenderOptions struct {
// symbols
HorizontalLink string
VerticalLink string
RootLink string
ChildLink string
LastChildLink string
ChildrenLink string
NodeSymbol string
// dimensions
MarginTop int
MarginBottom int
MarginLeft int
HorizontalLinkLength int
LabelPaddingLeft int
ChildrenMarginTop int
ChildrenMarginBottom int
}
RenderOptions is used to customize rendering
func NewRenderOptions ¶
func NewRenderOptions() *RenderOptions
NewRenderOptions generates default rendering options
func (*RenderOptions) Compact ¶
func (o *RenderOptions) Compact()
Compact override dimensions for a compact rendering
func (*RenderOptions) Dotted ¶
func (o *RenderOptions) Dotted()
Dotted override symbols for a dotted rendering
func (*RenderOptions) Rounded ¶
func (o *RenderOptions) Rounded()
Rounded override symbols for a rounded rendering
Source Files
¶
- dir.go
- render.go
- textree.go
Click to show internal directories.
Click to hide internal directories.
