Expand description
A handy little tool to create tree diagrams from MD headings
Β§About
This module sits on top of the GenTree structure and contains five functions:
- A top-level navigator function that takes a Path and a level setting to indicate the level that the output drawing should start at
- A [parse] function that takes a Path and outputs a list of headings
- A construct function that builds the
GenTree - A pretty_print function that traverses the tree and prints the contents to terminal
The overall output should look something like this,
π /document.md
β
βββ Landlocked
β βββ Switzerland
β β βββ Geneva
β β βββ Old Town
β β βββ CathΓ©drale Saint-Pierre
β βββ Bolivia
β βββ []
β βββ []
β βββ Puerta del Sol
β βββ Puerta de la Luna
βββ Islands
βββ Fresh Water
βββ AustraliaΒ§Design
This is mostly just an excuse to write recursive tree traversal functions. All functions but the parsing function utilize recursion.
StructsΒ§
FunctionsΒ§
- construct
- Constructs a tree of Heading types
- navigator
- A recursive function that chains the moduleβs utility functions to pretty-print a table of contents for each Markdown file in the specified directory; The is_file() path contains logic to build a tree from filtered values, skipping headers above the user-supplied level argument; The function also substitues the file name (if any) for all MD files not formatted with Astroβs frontmatter
- pretty_
print - A wrapper for a recursive preorder(ish) traversal function; Contains logic to print [] on empty trees for more appealing presentation Takes a reference to the GenTree and pretty-prints its contents.