https://github.com/blakeaw/mergram

Programmatically construct Mermaid diagrams and charts in Python

https://github.com/blakeaw/mergram

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
Last synced: 11 months ago · JSON representation

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
Created about 1 year ago · Last pushed about 1 year ago
Metadata Files
Readme License

README.md

MerGram

Programmatically generate Mermaid diagrams and charts using Python.

Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. Python version badge license release PyPI - Version Ruff PyPI Downloads

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 .mmd or .mermaid files
  • Optional integration with networkx for graph conversion

What's New in

v0.3.0

  • Style class that can be used to add style ... lines to flowcharts
  • Fixes to style-related outputs for nodes

v0.2.0

  • Flowchart.to_markdown function to get a string representation of the flowchart embedded in a Markdown Mermaid code block.
  • Flowchart.to_html function 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

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

Committers

Last synced: 12 months ago

All Time
  • Total Commits: 12
  • Total Committers: 1
  • Avg Commits per committer: 12.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 12
  • Committers: 1
  • Avg Commits per committer: 12.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
blakeaw b****2@g****m 12

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

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 34 Last month
Rankings
Dependent packages count: 8.9%
Average: 29.4%
Dependent repos count: 49.9%
Maintainers (1)
Last synced: 11 months ago

Dependencies

.github/workflows/python-publish-pypi.yml actions
  • 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
pyproject.toml pypi