codetree

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2019 License: MIT Imports: 3 Imported by: 2

README

codetree

Reference Report Tests Coverage License

Parses indented code (Python, Pug, Stylus, Pixy, codetree, etc.) and returns a tree structure.

Installation

go get github.com/aerogo/codetree

Usage

tree, err := codetree.New(source)
defer tree.Close()

Input

parent1
	child1
	child2
	child3
		child3.1
		child3.2
	child4

parent2
	child1

Output

See CodeTree structure.

The root node always starts with Indent being -1.

Author

Eduard Urbach on Twitter
Eduard Urbach

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeTree

type CodeTree struct {
	Line     string
	Children []*CodeTree
	Parent   *CodeTree
	Indent   int
}

CodeTree ...

func New

func New(src string) (*CodeTree, error)

New returns a tree structure if you feed it with indentantion based source code.

func (*CodeTree) Close

func (tree *CodeTree) Close()

Close sends the tree and all of its children back to the memory pool. The resources are therefore freed up and the tree object should not be used after the final Close() call anymore.

Jump to

Keyboard shortcuts

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