-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify API, second attempt #5
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goreadme diff for README.md file for this PR:
Path: README.md
# asciitree
-Package asciitree provides tools to build trees of entities and print them
+Package asciitree provides tools to build directory trees and print them
using ASCII art.
## Types
-### type [SortOption](/options.go#L4)
+### type [Node](/asciitree.go#L12)
-`type SortOption interface { ... }`
-
-SortOption represents an option that can be provided to the Sort method.
-
-#### func [WithBranchesFirst](/options.go#L16)
-
-`func WithBranchesFirst(value bool) SortOption`
-
-WithBranchesFirst is an option that makes the Sort method order branches
-before leaves.
-
-### type [Tree](/asciitree.go#L12)
-
-`type Tree struct { ... }`
-
-Tree represents a tree node.
-
-#### func [New](/asciitree.go#L19)
-
-`func New(title string) *Tree`
-
-New creates a tree node.
+`type Node struct { ... }`
-#### func [NewBranch](/asciitree.go#L24)
+Node represents a directory tree node.
-`func NewBranch(title string) *Tree`
+#### func [NewDir](/asciitree.go#L22)
-NewBranch creates a tree node and forces it to be recognized as a branch.
+`func NewDir(name string) *Node`
-#### func (*Tree) [Add](/asciitree.go#L32)
+NewDir creates a tree node and forces it to be recognized as a directory.
-`func (t *Tree) Add(titles ...string) *Tree`
+#### func [NewFile](/asciitree.go#L27)
-Add creates one or more tree nodes with the provided titles and appends them
-to the node's children.
+`func NewFile(name string) *Node`
-Unlike NewChild, Add returns the original node for chaining.
+NewFile creates a tree node.
-#### func (*Tree) [AddBranches](/asciitree.go#L44)
+#### func (*Node) [Add](/asciitree.go#L35)
-`func (t *Tree) AddBranches(titles ...string) *Tree`
+`func (t *Node) Add(nodes ...*Node) *Node`
-AddBranches creates one or more tree nodes with the provided titles, forces
-them to be recognized as branches, and appends them to the node's children.
+Add appends the provided tree nodes to the node's children.
-Unlike NewChildBranch, AddBranches returns the original node for chaining.
-
-#### func (*Tree) [AddTrees](/asciitree.go#L56)
-
-`func (t *Tree) AddTrees(trees ...*Tree) *Tree`
-
-AddTrees appends the provided tree nodes to the node's children.
-
-Unlike NewChild and NewChildBranch, AddTrees returns the original node for
+Unlike AddFile and AddDir, Add returns the original node for
chaining.
-#### func (*Tree) [IsBranch](/asciitree.go#L69)
+#### func (*Node) [AddDir](/asciitree.go#L46)
-`func (t *Tree) IsBranch() bool`
+`func (t *Node) AddDir(name string) *Node`
-IsBranch reports whether the node should be recognized as a branch. This is
-possible in two cases:
+AddDir creates a tree node, forces it to be recognized as a directory,
+and appends it to the node's children.
-- The node has one or more children.
-- The node was forced to be recognized as a branch by creating it with the
-NewBranch function or the NewChildBranch method.
+Unlike AddDirs, AddDir returns the newly created node.
-#### func (*Tree) [NewChild](/asciitree.go#L76)
+#### func (*Node) [AddDirs](/asciitree.go#L56)
-`func (t *Tree) NewChild(title string) *Tree`
+`func (t *Node) AddDirs(names ...string) *Node`
-NewChild creates a tree node and appends it to the node's children.
+AddDirs creates one or more tree nodes with the provided names, forces them
+to be recognized as directories, and appends them to the node's children.
-Unlike Add, NewChild returns the newly created node.
+Unlike AddDir, AddDirs returns the original node for chaining.
-#### func (*Tree) [NewChildBranch](/asciitree.go#L86)
+#### func (*Node) [AddFile](/asciitree.go#L67)
-`func (t *Tree) NewChildBranch(title string) *Tree`
+`func (t *Node) AddFile(name string) *Node`
-NewChildBranch creates a tree node, forces it to be recognized as a branch,
-and appends it to the node's children.
+AddFile creates a tree node and appends it to the node's children.
-Unlike AddBranches, NewChildBranch returns the newly created node.
+Unlike AddFiles, AddFile returns the newly created node.
-#### func (*Tree) [SetTitle](/asciitree.go#L95)
+#### func (*Node) [AddFiles](/asciitree.go#L77)
-`func (t *Tree) SetTitle(title string) *Tree`
+`func (t *Node) AddFiles(names ...string) *Node`
-SetTitle sets the node's title.
+AddFiles creates one or more tree nodes with the provided names and appends
+them to the node's children.
-SetTitle returns the original node for chaining.
+Unlike AddFile, AddFiles returns the original node for chaining.
-#### func (*Tree) [Sort](/asciitree.go#L103)
+#### func (*Node) [Sort](/asciitree.go#L88)
-`func (t *Tree) Sort(opts ...SortOption) *Tree`
+`func (t *Node) Sort(opts ...SortOption) *Node`
Sort recursively sorts the node's children in place.
Sort returns the original node for chaining.
-#### func (*Tree) [String](/asciitree.go#L120)
+#### func (*Node) [String](/asciitree.go#L105)
-`func (t *Tree) String() string`
+`func (t *Node) String() string`
String returns the tree's visual representation.
-#### func (*Tree) [Title](/asciitree.go#L125)
+### type [SortOption](/options.go#L8)
-`func (t *Tree) Title() string`
+`type SortOption interface { ... }`
+
+SortOption represents an option that can be provided to the Sort method.
-Title returns the node's title.
+#### func [WithDirsFirst](/options.go#L20)
+
+`func WithDirsFirst(value bool) SortOption`
+
+WithDirsFirst is an option that makes the Sort method order directories
+before leaves.
---
Readme created from Go doc with [goreadme](https://github.com/posener/goreadme)
ac89faa
to
030be85
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR:
NewChild<noun>
toAdd<noun>
.Node
struct.