Tree

The Tree renderable shows hierarchical structures:

import Term.Trees: Tree

data = Dict(
    "a" => 1,
    "b" => Int64,
    "c" => (1, 2, 3),
)

print(Tree(data))
 tree
━━━━━━
  
  ├── c: (1, 2, 3)
  ├── b: Int64
  └── a: 1

As you can see, the starting point is a Dict with key -> value entries which get rendered as leaves in the tree. Also, the Type of value is shown by colors in the tree.

If you have nested data, just create nested dictionaries!

data = Dict(
    "a" => 1,
    "b" => Int64,
    "deep" => Dict(
            "x" => 1,
            "y" => :x
    ),
)

print(Tree(data))
 tree
━━━━━━
  
  ├── deep
  │   ├── x: 1
  │   └── y: x
  ├── b: Int64
  └── a: 1

Easy! Tree has lots of options to allow you to style it as you like:

print(
    Tree(data,
        title="my custom tree",
        title_style="red",
        guides_style="green",
        guides_type=:boldtree

    )
)
 my custom tree
━━━━━━━━━━━━━━━━
       
       ┣━━ deep
       ┃   ┣━━ x: 1
       ┃   ┗━━ y: x
       ┣━━ b: Int64
       ┗━━ a: 1

And of course trees behave just like any renderable so you can create layouts with them:

import Term: Panel, Tree
data = Dict(
    "a" => 1,
    "b" => Int64,
    "deep" => Dict(
            "x" => 1,
            "y" => :x
    ),
)

tree = Tree(data)

print(
    ("\n" / tree) * "  " * Panel(tree; fit=true)
)
                ╭──────────────────╮
 treetree━━━━━━━━━━━━├── deep├── deep│   ├── x: 1│   ├── x: 1│   └── y: x  │    │   └── y: x  │
  ├── b: Int64  │    ├── b: Int64  │
  └── a: 1└── a: 1      │
                ╰──────────────────╯
Entries order

Used OrderedCollections.OrderedDict instead of Dict if you want to specify the order of entries in the Tree.

TypeTree

As you know, Julia allows for hierarchical types structures. Trees are for visualizing hierarchical data structures. So...

import Term: typestree

typestree(AbstractFloat)
╭────────────── Types hierarchy ───╮
                                  
  Number                          
 ━━━━━━━━                         
                              
    ├── Complex                   
    └── Real                      
        ├── Rational              
        ├── AbstractIrrational    
        ├── AbstractFloat         
        │   ├── BigFloat          
        │   ├── Float32           
        │   ├── Float64           
        │   └── Float16           
        └── Integer               
                                  
╰──────────────────────────────────╯

Enjoy!