Documentation
¶
Overview ¶
Package tree provides functionality to render tree structures
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultTreeStyle = TreeStyle{
CharItemVertical: "│ ",
CharItemMiddle: "├─",
CharItemBottom: "└─",
CharChildIndicator: " ●",
}
Functions ¶
This section is empty.
Types ¶
type Renderer ¶
Renderer prints a tree from a DirectedAcyclicGraph as a table. Columns: NESTING, COMPONENT, VERSION, PROVIDER, IDENTITY. NESTING shows the tree structure using Unicode box-drawing characters from TreeStyle.
Example output:
NESTING COMPONENT VERSION PROVIDER IDENTITY ├─ ● app-frontend v1.2.0 acme A │ ├─ ● ui-library v2.1.0 acme B │ │ └─ icons v1.0.0 other C │ └─ api-client v3.0.0 acme D ├─ ● app-backend v2.0.0 acme X │ └─ database v1.1.0 acme Y └─ cache-layer v0.9.0 other Z
func New ¶
func New[T cmp.Ordered](ctx context.Context, dag *syncdag.DirectedAcyclicGraph[T], opts ...RendererOption[T]) *Renderer[T]
New creates a new Renderer for the given DirectedAcyclicGraph.
type RendererOption ¶
type RendererOption[T cmp.Ordered] func(*RendererOptions[T])
RendererOption is a function that modifies the RendererOptions.
func WithRoots ¶
func WithRoots[T cmp.Ordered](roots ...T) RendererOption[T]
WithRoots sets the roots for the Renderer.
func WithVertexSerializer ¶
func WithVertexSerializer[T cmp.Ordered](serializer VertexSerializer[T]) RendererOption[T]
WithVertexSerializer sets the VertexSerializer for the Renderer.
func WithVertexSerializerFunc ¶
func WithVertexSerializerFunc[T cmp.Ordered](serializerFunc func(*syncdag.Vertex[T]) (Row, error)) RendererOption[T]
WithVertexSerializerFunc sets the VertexSerializer based on a function.
type RendererOptions ¶
type RendererOptions[T cmp.Ordered] struct { // VertexSerializer serializes a vertex into a Row. VertexSerializer VertexSerializer[T] // Roots are the root vertices of the tree to render. Roots []T // TableStyle allows customizing the go-pretty table style used by the renderer. TableStyle table.Style }
RendererOptions defines the options for the tree Renderer.
type TreeStyle ¶
type TreeStyle struct { // CharItemVertical is the character used for vertical lines (│) CharItemVertical string // CharItemMiddle is the character used for middle branch connectors (├─) CharItemMiddle string // CharItemBottom is the character used for bottom branch connectors (└─) CharItemBottom string // CharChildIndicator is the character used to indicate nodes with children (●) CharChildIndicator string }
TreeStyle defines the Unicode characters used for rendering tree structures.
type VertexSerializer ¶
VertexSerializer is an interface that defines a method to serialize a vertex.