Skip to main content

dot2mermaid

A library for converting dot file to mermaid and markdown.

Requirements:

- graphviz
- code2flow
- pygraphviz

Windows users should install pygraphviz after graphviz by:

py -m pip install --use-pep517 --config-settings="--global-option=build_ext"  --config-settings="--global-option=-IC:\Program Files\Graphviz\include"  --config-settings="--global-option=-LC:\Program Files\Graphviz\lib" pygraphviz

After proper installation, try:

from dot2mermaid import DotParser, get_dot

path = "./path/to/your/code/directory"
dot_file = get_dot(path)
parser = DotParser(dot_file)
colors = {
    'regular': '#555555',
    'trunk': '#AA5555',
    'leaf': '#5555FF'
}
markdown_content = parser.to_mermaid(colors=colors)
parser.add_to_markdown('./README.md', markdown_content)  # to replace mermaid
graph LR
    %% Subgraphs
    subgraph File: dot2mermaid
        direction LR
        subgraph Class: DotParser
            direction LR
            node_e87307ce["62: _parse_legend_colors()"]:::leaf
            node_4ae5ed1a["44: _parse_subgraphs()"]:::filled
            node_9e04e6af["151: add_to_markdown()"]:::trunk
            node_1435b8f8["130: create_node_style()"]:::leaf
            node_ba5c8ee4["119: edges_to_mermaid()"]:::filled
            node_6fed536c["77: get_edges()"]:::leaf
            node_c9b26d7f["74: get_subgraphs()"]:::filled
            node_4c63ab74["91: subgraphs_to_mermaid()"]:::filled
            node_c0357d7b["137: to_mermaid()"]:::trunk
        end
        node_e87307ce["62: _parse_legend_colors()"]:::leaf
        node_4ae5ed1a["44: _parse_subgraphs()"]:::filled
        node_9e04e6af["151: add_to_markdown()"]:::trunk
        node_1435b8f8["130: create_node_style()"]:::leaf
        node_ba5c8ee4["119: edges_to_mermaid()"]:::filled
        node_6fed536c["77: get_edges()"]:::leaf
        node_c9b26d7f["74: get_subgraphs()"]:::filled
        node_4c63ab74["91: subgraphs_to_mermaid()"]:::filled
        node_c0357d7b["137: to_mermaid()"]:::trunk
        node_3a20c0f3["20: get_dot()"]:::trunk
        node_98f88cb0["9: read()"]:::leaf
        node_ec40940c["15: save()"]:::leaf
    end

    %% Edges
    node_4ae5ed1a --> node_e87307ce
    node_4ae5ed1a --> node_4ae5ed1a
    node_9e04e6af --> node_98f88cb0
    node_9e04e6af --> node_ec40940c
    node_ba5c8ee4 --> node_6fed536c
    node_c9b26d7f --> node_4ae5ed1a
    node_4c63ab74 --> node_c9b26d7f
    node_c0357d7b --> node_1435b8f8
    node_c0357d7b --> node_ba5c8ee4
    node_c0357d7b --> node_4c63ab74
    node_3a20c0f3 --> node_98f88cb0

    %% Edge styles
    linkStyle 0 stroke:#56B4E9
    linkStyle 1 stroke:#56B4E9
    linkStyle 2 stroke:#CC79A7
    linkStyle 3 stroke:#CC79A7
    linkStyle 4 stroke:#F0E442
    linkStyle 5 stroke:#CC79A7
    linkStyle 6 stroke:#F0E442
    linkStyle 7 stroke:#009E73
    linkStyle 8 stroke:#009E73
    linkStyle 9 stroke:#009E73
    linkStyle 10 stroke:#009E73

    %% Node styles
    classDef filled fill:#555555,stroke:#000000,stroke-width:2px;
    classDef leaf fill:#5555FF,stroke:#000000,stroke-width:2px;
    classDef trunk fill:#AA5555,stroke:#000000,stroke-width:2px;

Compare it with code2flow png file:

package.png

Release files for dot2mermaid 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dot2mermaid 0.3.0
File Size Uploaded
dot2mermaid-0.3.0.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dot2mermaid 0.3.0
File Interpreter ABI Platform
dot2mermaid-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.3 kB

Release files / dot2mermaid-0.3.0.tar.gz

Download URL dot2mermaid-0.3.0.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7e1c7c1e2b26ba50894858c4ff7e5872ad32b73dbfc064b8f460ce919229fe88
BLAKE2b-256 checksum
How to use checksums
55c48bc9200574d68456e2ffbf4a3de64b223d689e13b1710be3dd7650826380
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.6 Windows/10

Release files / dot2mermaid-0.3.0-py3-none-any.whl

Download URL dot2mermaid-0.3.0-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64fd4c2d935069a7211f574c1ae08143e9c403f9e1a526e313cc93b7f8d93b6f
BLAKE2b-256 checksum
How to use checksums
b0cdf7b3592f64002b51ca17467bd67a18e14036c8856d0b38e258b3bee35bf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.6 Windows/10

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page