nodes

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Formatter

type Formatter interface {
	String() string
	// contains filtered or unexported methods
}

Formatter provides all functions needed to

func BuildFormatter

func BuildFormatter(indentWidth int, monochrome bool, fileType input.FileType) Formatter

BuildFormatter builds the correct formatter according to its parameters.

type Label

type Label struct {
	// contains filtered or unexported fields
}

Label represents all info needed to print a nice node label

func (Label) String

func (l Label) String(monochrome bool) string

type Node

type Node interface {

	// Label contains additional info for nicer output.
	Label() Label

	// Path is the JSONPath of the node (http://goessner.net/articles/JsonPath/).
	Path() string

	// Children contains all children of the node, might be empty.
	Children() []Node

	// Format writes the formatted node (and its children) into a formatter.
	Format(f Formatter, indentLvl int)

	// IsCollapsable determinates if a node can collapse its children.
	IsCollapsable() bool

	// IsCollapsed is the current state of collapse.
	IsCollapsed() bool

	// ToggleExpansion tries to toggle the current state of expansion/collapse.
	ToggleExpansion()
}

Node represents the comcept of a generic node that mostly key/value-based.

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

Tree represents a tree of nodes with a single root

func NewTree

func NewTree(fileType input.FileType, raw interface{}) (*Tree, error)

NewTree builds a new tree

func (Tree) FileType

func (t Tree) FileType() input.FileType

FileType return the input.FileType of the tree

func (*Tree) Root

func (t *Tree) Root() Node

Root returns the root node of the tree

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL