Skip to main content

Convert Graphviz DOT files to ASCII box-drawing art

Project description

hascii

Convert Graphviz DOT files to ASCII box-drawing art.

hascii reads a DOT graph, uses Graphviz for layout, and renders the result using Unicode box-drawing characters -- suitable for embedding in source code, docstrings, and plain-text documentation.

Example

                  ┌─────────────────────────┐
                  │ start_while_simple_flow │
                  └─────────────────────────┘
                               │
                               │
                               ▼
                       ┏┅┅┅┅┅┅┅┅┅┅┅┅┅┅┓
                       ┇ handler_init ┇
                       ┗┅┅┅┅┅┅┅┅┅┅┅┅┅┅┛
                               │
                               │
                               ▼
           ┌┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┐
           ┆ router_while_simple_flow_seq_set_i_2 ┆
           ┆                                      ┆
           ┆              p['i'] = 0              ┆
           └┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┘
                               │
                               │
                               ▼
    ┌┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┐
 ┌─▶┆ router_while_simple_flow_while_i_lt_max_iterations ┆
 │  └┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┘
 │                             │p['i'] < p['max_iterations']
 │                             └─────────────────────────────────┐
 │                             │                                 │else
 │                             ▼                                 │
 │          ┌┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┐               ▼
 │          ┆ router_while_simple_flow_seq_set_i ┆     ┌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┐
 │          ┆                                    ┆     ╎ handler_finalize ╎
 │          ┆            p['i'] += 1             ┆     └╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┘
 │          └┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┘               │
 │           ┌─────────────────┘                                 │
 │           ▼                                                   │
 │  ┏┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┓                                          ▼
 └──┇ handler_process ┇                                          ●
    ┗┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┛
Source DOT and rendered PNG

DOT source: flow.dot

Graphviz rendering:

flow.png

Node fill colors are represented as border styles (--no-color mode):

Border Color family Example colors
┌──┐ │ solid Green palegreen
┌┄┄┐ ┆ light triple-dash Orange/Yellow wheat, gold
┌╌╌┐ ╎ light double-dash Red lightsalmon, coral
┏┅┅┓ ┇ heavy triple-dash Blue lightblue, cyan
┏╍╍┓ ╏ heavy double-dash Purple/Pink plum, pink
┏━━┓ ┃ heavy solid Dark black, darkgray
‥‥‥ ‥ two-dot leader Light achromatic white, lightgray

When output goes to a terminal, borders are colored with ANSI codes instead. Use --no-color for plain text suitable for docstrings and files.

Features

  • Configurable maximum output width (--width)
  • Multiple label trimming strategies (--trim): end, start, middle, smart
  • Edge labels placed adjacent to their edges, never truncated
  • Back-edge routing with direction-aware LEFT/RIGHT detection
  • Fan-in/fan-out bus routing for clean merge/split lines
  • Hue-based border styles (B/W) + ANSI foreground colors (TTY)
  • Usable as both a CLI tool and a Rust library

Installation

From source (requires Rust toolchain and Graphviz):

cargo install --path .

Or build without installing:

cargo build --release

Graphviz must be installed and the dot command available in PATH:

# Debian / Ubuntu
sudo apt-get install graphviz

# macOS
brew install graphviz

Usage

hascii [OPTIONS] [FILE]

Options:
      --stdin                  Read DOT source from stdin
      --width <WIDTH>          Maximum output width in characters
      --trim <TRIM>            Label trimming strategy [default: smart]
      --max-label <MAX_LABEL>  Maximum label width in characters
      --no-color               Disable ANSI colors (use border styles instead)
  -v, --verbose...             Increase verbosity (-v, -vv, -vvv)
  -h, --help                   Print help

Examples:

# Render a DOT file
hascii flow.dot

# Pipe from stdin
echo 'digraph { A -> B -> C }' | hascii --stdin

# Constrain width for docstrings
hascii --width 72 --no-color flow.dot > flow.txt

# Trim long labels
hascii --max-label 30 flow.dot

Trimming strategies

When labels exceed the available space, hascii trims them using --trim:

Strategy Example (budget 25) Description
end router_text_impro... Keep prefix, append ellipsis
start ...score_ge_threshold Prepend ellipsis, keep suffix
middle router_te...threshold Keep prefix and suffix, ellipsis in middle
smart router_text...threshold Split on _, keep informative word boundaries

smart (the default) splits on underscores and greedily keeps whole segments from both ends.

Python usage

pip install hascii
import hascii

dot = 'digraph { A -> B -> C }'
print(hascii.render(dot))

# With options
print(hascii.render(dot, max_width=60, trim="smart", no_color=True))

# From file
print(hascii.render_file("flow.dot"))

Requires Graphviz (dot) installed on the system.

Rust library usage

use hascii::{render, RenderOptions};

let dot = r#"digraph { A -> B -> C }"#;
let options = RenderOptions::default();
let ascii = render(dot, &options).expect("render failed");
println!("{ascii}");

License

Apache-2.0

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

hascii-0.1.0-cp313-cp313-win_amd64.whl (273.0 kB view details)

Uploaded CPython 3.13Windows x86-64

hascii-0.1.0-cp313-cp313-manylinux_2_39_x86_64.whl (402.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.39+ x86-64

hascii-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (343.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

hascii-0.1.0-cp312-cp312-win_amd64.whl (273.6 kB view details)

Uploaded CPython 3.12Windows x86-64

hascii-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl (403.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

hascii-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (344.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

hascii-0.1.0-cp311-cp311-win_amd64.whl (273.4 kB view details)

Uploaded CPython 3.11Windows x86-64

hascii-0.1.0-cp311-cp311-manylinux_2_39_x86_64.whl (403.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.39+ x86-64

hascii-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (346.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

hascii-0.1.0-cp310-cp310-win_amd64.whl (273.4 kB view details)

Uploaded CPython 3.10Windows x86-64

hascii-0.1.0-cp310-cp310-manylinux_2_39_x86_64.whl (403.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.39+ x86-64

hascii-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (346.1 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

hascii-0.1.0-cp39-cp39-win_amd64.whl (273.2 kB view details)

Uploaded CPython 3.9Windows x86-64

hascii-0.1.0-cp39-cp39-manylinux_2_39_x86_64.whl (403.6 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.39+ x86-64

hascii-0.1.0-cp39-cp39-macosx_11_0_arm64.whl (346.1 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file hascii-0.1.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: hascii-0.1.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 273.0 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hascii-0.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2c91fb66988c7f9a988d1e037ac78ea84ad21d9f1a27aa4b4e1c8b6b2c19f796
MD5 a67745129b8c02518990b84f8c3da629
BLAKE2b-256 6ddb818dc30e6b58bbb31bd8f7b5fb3fa4aff8e72fefcab59a2780c9be89aa96

See more details on using hashes here.

Provenance

The following attestation bundles were made for hascii-0.1.0-cp313-cp313-win_amd64.whl:

Publisher: release.yml on atemate/hascii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hascii-0.1.0-cp313-cp313-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for hascii-0.1.0-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 f4df5a518ba3d205eaa8a4c33e136271d49f4b7fdb9fbc74e5f6fde450340d8e
MD5 9764b04df57200540977c8fd16593f9e
BLAKE2b-256 1bcaf2710dd3c6be44901d37a62aa5f38d35c241630f64182e6e4dd7f6a1a2c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for hascii-0.1.0-cp313-cp313-manylinux_2_39_x86_64.whl:

Publisher: release.yml on atemate/hascii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hascii-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hascii-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b224c5468ba7b071e133196a5034f8058f6f18255ce0a68d2f83cda6fc6b31d4
MD5 7a548ff6b7d42774720fc40e3902b936
BLAKE2b-256 b1a1c6cf01135d3f57b768b37d810a0863244172a5f75a162f4119fead6d3b53

See more details on using hashes here.

Provenance

The following attestation bundles were made for hascii-0.1.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on atemate/hascii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hascii-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: hascii-0.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 273.6 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hascii-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 77b0e5d4539ac7490ba4061973316deb75a7543434c0c26eba7d9aa5458f26ee
MD5 f4b1a91f12448878a67dbc4b05e3dc4c
BLAKE2b-256 e25d1e1d1fb1fee66a631bf55d854e56dab4275da479de950bdfd786433ca21f

See more details on using hashes here.

Provenance

The following attestation bundles were made for hascii-0.1.0-cp312-cp312-win_amd64.whl:

Publisher: release.yml on atemate/hascii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hascii-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for hascii-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 ff951940ba345c9e1ce5b860d3a6572aad697de712e98053a5fc8f1bbed2c0e6
MD5 cacc99e6cc1c2682a927ac7c94ee196d
BLAKE2b-256 59b325b0fdb383358c940fd76532ce1367db026f2f9ea9bcb9c4ac910e74f376

See more details on using hashes here.

Provenance

The following attestation bundles were made for hascii-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl:

Publisher: release.yml on atemate/hascii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hascii-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hascii-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 80d17d335b081f34e499c5a6966f751f46899e4a9be4e26c4a6f19487b9c425b
MD5 d5544b20476d1ce7161cbef0244794bc
BLAKE2b-256 c0a3a4b45fe49611ccb3908ce8c5ce7611199a75bfb96c5511c28ed6b9393f00

See more details on using hashes here.

Provenance

The following attestation bundles were made for hascii-0.1.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on atemate/hascii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hascii-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: hascii-0.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 273.4 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hascii-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3168202323687cbc6a781a9edc179760f4c8b3409bdce06624c7b866a358bf70
MD5 16892634684147560953c8772b8b7cce
BLAKE2b-256 c73adac8953d206f90d20d030288795a19693cd5894b82b700948dcc82357dce

See more details on using hashes here.

Provenance

The following attestation bundles were made for hascii-0.1.0-cp311-cp311-win_amd64.whl:

Publisher: release.yml on atemate/hascii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hascii-0.1.0-cp311-cp311-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for hascii-0.1.0-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 91c69e40430b5c59b7157fc2c2e92b7c2ff0caf17714f3a0bd5eda450be8f173
MD5 0b3cdd6fed171a0935eaf5a7b2fe4e73
BLAKE2b-256 919bc307ddebe8182fbd504410233732c667ca8b774e1cd2f9664ad3be87461a

See more details on using hashes here.

Provenance

The following attestation bundles were made for hascii-0.1.0-cp311-cp311-manylinux_2_39_x86_64.whl:

Publisher: release.yml on atemate/hascii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hascii-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hascii-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4716d03a72d3ac136c71736a1856ded0e230c47b423dae8540aaedfbb75444a2
MD5 b43ff4d177f595232fd5723af69e60ba
BLAKE2b-256 40580723240e85843d88d1ebac772540a31f6543846ea9a1e140ba622682ab39

See more details on using hashes here.

Provenance

The following attestation bundles were made for hascii-0.1.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on atemate/hascii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hascii-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: hascii-0.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 273.4 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hascii-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cdff8c279ca9c1c40551153aeb8cac7a2bdfd4f1d91051fc91ed60f29876049e
MD5 1116a56c068050dfa69595b3f67e12cf
BLAKE2b-256 1c6403c9ae4ab300ad4557dd595357fafe981a6d39025e251a110998ea8fb3ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for hascii-0.1.0-cp310-cp310-win_amd64.whl:

Publisher: release.yml on atemate/hascii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hascii-0.1.0-cp310-cp310-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for hascii-0.1.0-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 11db8c982d9339aa110bc96214812246c607316790ed0575792c3514a35271d7
MD5 28200993ff3657c311debc25b84043bf
BLAKE2b-256 1a6ad41008afd1f84f028222243da84c27e71a883863056bdba3389d1be27a9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for hascii-0.1.0-cp310-cp310-manylinux_2_39_x86_64.whl:

Publisher: release.yml on atemate/hascii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hascii-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hascii-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b9dc7682adf2b53865c9c322a6f9ea360c9aa5aabb26db0663b0aca817e86199
MD5 ea47bdf005f1403ca7b973897c5cc8e8
BLAKE2b-256 36d86fd1ccf95eb2912b99e0b85b68289f615a3e72d477c60d8ed876d6bec27e

See more details on using hashes here.

Provenance

The following attestation bundles were made for hascii-0.1.0-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on atemate/hascii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hascii-0.1.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: hascii-0.1.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 273.2 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hascii-0.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 73a5b4713203e300412a3a76498f6684f2e03d52ddf0a1809419638b85e5dd98
MD5 84b72acf9200793c7c852b3dd8122807
BLAKE2b-256 5defa06a19dea890153d3c5582cb8136ae8bfc93e0ca6abfb1ce9fe37a1724ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for hascii-0.1.0-cp39-cp39-win_amd64.whl:

Publisher: release.yml on atemate/hascii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hascii-0.1.0-cp39-cp39-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for hascii-0.1.0-cp39-cp39-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 0cce08b3556a90f68cc29f7ba1a1f18e3dc84174dd97d8036472cfe85b2d02cc
MD5 f37999d7af20766131d842089bab3abd
BLAKE2b-256 c31d55fcb9a32fba1944aa36300e39e58b58b6e90f8dd02ce05a208adcaa6820

See more details on using hashes here.

Provenance

The following attestation bundles were made for hascii-0.1.0-cp39-cp39-manylinux_2_39_x86_64.whl:

Publisher: release.yml on atemate/hascii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hascii-0.1.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hascii-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3802d9903dc2ccf43da36612674878db1c04f6930c0214a0f46a8d5c75310186
MD5 627de5cf5a396462a43b9b7d3f78e1ac
BLAKE2b-256 807f7c422be7de198d795cb4d31844738266954c38938314e2f29112a98f0b99

See more details on using hashes here.

Provenance

The following attestation bundles were made for hascii-0.1.0-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: release.yml on atemate/hascii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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