TreeViz: Terminal Tree Renderer#

class arch.tools.viz.tree.TreeViz(*, root_dir=<factory>, root_idx=<factory>, max_depth=0, dry=False, acc={})#

A tree walker that traverses architectonic directories, accumulating printable output.

classmethod new(idx, **kwargs)#

Build a walker rooted at the directory for the given index.

arch_iter(idx, _dir, *tasks, depth=0, color=-1)#

Walk the tree from an index, running tasks on each node’s files and recording output.

Parameters:
  • idx – The index of the current node.

  • _dir – The directory corresponding to the index.

  • *tasks – Callbacks producing content lines from (idx, files, color).

  • depth – The current recursion depth.

  • color – The color chamber inherited from the depth-1 ancestor.

walk(*tasks)#

Run the named tasks over the whole tree, then print the accumulated output.

Parameters:

*tasks – Names of task methods to run on each node, e.g. ‘tree’ or ‘data’.

tree(idx, files, color, processor=None)#

List each node’s files by their root-relative paths, colorized by chamber.

Parameters:
  • idx – The index of the current node.

  • files – The instance files found below the node.

  • color – The color chamber to render with.

  • processor – An optional callback producing extra content lines per file.

Returns:

One line per file (plus any processor output), colorized for printing.

data(idx, files, color)#

List each node’s files along with their parsed dataclass members.

modify(idx, files, color)#

Apply a one-off bulk edit to each node’s files, reporting a status line per file.

The edit itself is rewritten in place for each new migration task; it currently appends a register_element() call to any architectonic class file missing one. With dry set, a unified diff is reported instead of writing.

document(idx, files, color)#

Render each node’s division and element docstring, fitted to the terminal.

divide(idx, files, color)#

Render each node’s division, aligned against its siblings’ divisions.

model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].