https://github.com/blakeaw/mergram
Programmatically construct Mermaid diagrams and charts in Python
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.5%) to scientific vocabulary
Repository
Programmatically construct Mermaid diagrams and charts in Python
Basic Info
- Host: GitHub
- Owner: blakeaw
- License: mit
- Language: Python
- Default Branch: main
- Size: 24.4 KB
Statistics
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
- Releases: 3
Metadata Files
README.md
MerGram
Programmatically generate Mermaid diagrams and charts using Python.
MerGram currently supports constructing Mermaid flowcharts, with plans to expand support for additional diagram and chart types in future releases.
Features
- Build Mermaid flowcharts using Python classes
- Support for nodes, links, and subgraphs, and style assignments
- Export diagrams to Mermaid
.mmdor.mermaidfiles - Optional integration with networkx for graph conversion
What's New in
v0.3.0
Styleclass that can be used to addstyle ...lines to flowcharts- Fixes to style-related outputs for nodes
v0.2.0
Flowchart.to_markdownfunction to get a string representation of the flowchart embedded in a Markdown Mermaid code block.Flowchart.to_htmlfunction to get a string representation of the flowchart embedded in HTML.
Installation
bash
pip install mergram
To enable networkx integration:
bash
pip install mergram[networkx]
Usage
Basic Flowchart
```python from mergram.flowchart import Flowchart, Node, Link
fc = Flowchart("Example Flowchart") a = Node("A", label="Start") b = Node("B", label="End", shape='circle') fc += a fc += b fc += Link(a, b, text="to end")
print(fc) ``` Generates the following mermaid diagram code:
---
title: Example Flowchart
---
flowchart TB
A@{ shape: rect, label: Start }
B@{ shape: circle, label: End }
A-->|to end|B
style A fill:#fff, stroke:#000, stroke-width:2px, color:#000
style B fill:#fff, stroke:#000, stroke-width:2px, color:#000
That looks like:
```mermaid
title: Example Flowchart
flowchart TB A@{ shape: rect, label: Start } B@{ shape: circle, label: End } A-->|to end|B style A fill:#fff, stroke:#000, stroke-width:2px, color:#000 style B fill:#fff, stroke:#000, stroke-width:2px, color:#000 ```
From NetworkX
```python import networkx as nx from mergram.flowchart import Flowchart
G = nx.DiGraph() G.addedge("A", "B", label="to B") G.addedge("B", "A", label="to A") fc = Flowchart("From NetworkX", orientation='LR') fc.from_networkx(G) print(fc) ``` --- title: From NetworkX --- flowchart LR B@{ shape: rect, label: B } A@{ shape: rect, label: A } A-->|to B|B B-->|to A|A style A fill:#fff, stroke:#000, stroke-width:2px, color:#000 style B fill:#fff, stroke:#000, stroke-width:2px, color:#000
```mermaid
title: From NetworkX
flowchart LR B@{ shape: rect, label: B } A@{ shape: rect, label: A } A-->|to B|B B-->|to A|A style A fill:#fff, stroke:#000, stroke-width:2px, color:#000 style B fill:#fff, stroke:#000, stroke-width:2px, color:#000 ```
Export to File
python
fc.write("diagram.mmd")
Optional Dependencies
networkx: For converting existing graphs to Mermaid flowcharts.
License
MIT License
Contributing
Contributions are welcome! Please open issues or pull requests.
Owner
- Name: Blake A. Wilson
- Login: blakeaw
- Kind: user
- Location: Texas, USA
- Website: https://blakeaw.github.io/
- Repositories: 4
- Profile: https://github.com/blakeaw
Computational research science in physical chemistry, systems biology, and nanomaterials bioengineering.
GitHub Events
Total
- Release event: 3
- Watch event: 1
- Delete event: 2
- Push event: 6
- Pull request event: 2
- Create event: 7
Last Year
- Release event: 3
- Watch event: 1
- Delete event: 2
- Push event: 6
- Pull request event: 2
- Create event: 7
Issues and Pull Requests
Last synced: 12 months ago
Packages
- Total packages: 1
-
Total downloads:
- pypi 34 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 3
- Total maintainers: 1
pypi.org: mergram
Programmatically construct Mermaid diagrams and charts in Python
- Documentation: https://mergram.readthedocs.io/
- License: MIT
-
Latest release: 0.3.0
published about 1 year ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v4 composite
- actions/download-artifact v4 composite
- actions/setup-python v5 composite
- actions/upload-artifact v4 composite
- pypa/gh-action-pypi-publish release/v1 composite