Skip to main content

Terminal AST visualizer for document trees

Project description

3viz, a terminal AST visualizer for document trees

3viz is designed to simplify reasoning about document trees. The one-line-per-node and columnar layout makes scanning and understanding structure easy, while the textual representations, icons and metadata provide additional information at a glance.

Being line-based, it makes diffing trees useful and can be invaluable in debugging parse trees.

This is a sample output:

⧉ Document                                                                                                                                         7L
  ¶ This is a paragraph:                                                                                                                         2L
    ↵ This is a paragraph:                                                                                                                       1L
    ↵ With two lines.                                                                                                                               1L
    ↵ This document is the nanos spec, showing all elements, but not covering their full variation   1L
  № List                                                                                                                            type=ordered 2L
    §"Session And titles                                                                                                                           2L
      ⊤"Session And titles                                                                                                                        1L
      ⊡ Content                                                                                                                                         1L
        № List                                                                                                                     type=ordered  1L
          •     2. Core Elements                                                                                                                  2L
            ◦     2. Core Elements                                                                                                               1L
            ⊡ Content                                                                                                                                  1L
              ¶         Which should have at least one item.                                                                          1L
                ↵ Which should have at least one item.                                                                                1L
  𝒱 4. A simple code block: (-)                                                                                              13L

Installing

3viz is available on PyPI as treeviz-py, and can be installed with your preferred Python package manager:

$ pipx install treeviz-py  # recommended for global availability

Using 3viz

3viz can be used as a CLI:

$ 3viz <tree_path> <tree_format>

Or as a library:

from treeviz import generate_viz

# Both document and format can be a path to a file, strings, or Python objects
generate_viz(document, format)

Built-in adapters

  • mdast: Markdown Abstract Syntax Tree format used by remark and other Markdown processors
  • unist: Universal Syntax Tree format, the base format for unified ecosystem parsers
  • pandoc: Pandoc's JSON AST format for converting between markup formats
  • restructuredtext: reStructuredText document trees from the docutils library

Learn more

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

treeviz_py-0.0.2.tar.gz (48.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

treeviz_py-0.0.2-py3-none-any.whl (64.9 kB view details)

Uploaded Python 3

File details

Details for the file treeviz_py-0.0.2.tar.gz.

File metadata

  • Download URL: treeviz_py-0.0.2.tar.gz
  • Upload date:
  • Size: 48.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.11 Darwin/24.5.0

File hashes

Hashes for treeviz_py-0.0.2.tar.gz
Algorithm Hash digest
SHA256 8078f3f5ff995529220fd89a011c90638d9d81efda46a32d18096b9a1f310c0c
MD5 75ee50471ff2287c55ff5b77986c74e4
BLAKE2b-256 10933dc62c8c4f609c6276c411e411dfc245bc2b3b1750a4354e6ef56080071b

See more details on using hashes here.

File details

Details for the file treeviz_py-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: treeviz_py-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 64.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.11 Darwin/24.5.0

File hashes

Hashes for treeviz_py-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4ed9ca28af79bce61d4c0f7fa2ee56073689ca3cb50a5a6b371de8f43e05f85a
MD5 fee169806cc69738f85171ddb654018c
BLAKE2b-256 08bd61651b6e05e15619703b6deae138a1eafd3617eaad9a515b073085a1fd35

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page