A library for converting dot file to mermaid and markdown.
Project description
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:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dot2mermaid-0.3.0.tar.gz
(4.4 kB
view details)
Built Distribution
File details
Details for the file dot2mermaid-0.3.0.tar.gz
.
File metadata
- Download URL: dot2mermaid-0.3.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.6 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e1c7c1e2b26ba50894858c4ff7e5872ad32b73dbfc064b8f460ce919229fe88 |
|
MD5 | 62f62b7a11d08218807895cb347499ba |
|
BLAKE2b-256 | 55c48bc9200574d68456e2ffbf4a3de64b223d689e13b1710be3dd7650826380 |
File details
Details for the file dot2mermaid-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: dot2mermaid-0.3.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.6 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64fd4c2d935069a7211f574c1ae08143e9c403f9e1a526e313cc93b7f8d93b6f |
|
MD5 | e78124af416eaa0e1a7343d6942c8ed1 |
|
BLAKE2b-256 | b0cdf7b3592f64002b51ca17467bd67a18e14036c8856d0b38e258b3bee35bf1 |