Dynnammo / python_mermaid

GNU General Public License v3.0
28 stars 7 forks source link

Python-Mermaid

This modules aims to implement a simple way for developers/admin-sys/devops to create on-the-fly Mermaid diagrams.

✅ Use of this module when:

❌ Do not use this module for

Installation

pip install python_mermaid

How to use

All examples are available here

Run the script below to see diagram generation

# Creating a simple flowchart diagram
from python_mermaid.diagram import (
    MermaidDiagram,
    Node,
    Link
)

# Family members
meg = Node("Meg")
jo = Node("Jo")
beth = Node("Beth")
amy = Node("Amy")
robert = Node("Robert March")

the_march_family = [meg, jo, beth, amy, robert]

# Create links
family_links = [
    Link(robert, meg),
    Link(robert, jo),
    Link(robert, beth),
    Link(robert, amy),
]

chart = MermaidDiagram(
    title="Little Women",
    nodes=the_march_family,
    links=family_links
)

print(chart)

Returns the following

---
title: Little Women
---
graph 
meg["Meg"]
jo["Jo"]
beth["Beth"]
amy["Amy"]
robert_march["Robert March"]
robert_march ---> meg
robert_march ---> jo
robert_march ---> beth
robert_march ---> amy

which results can be seen here

Roadmap

October 2023

1-to-1 implementation of flowchart

November 2023

End 2023

Quick commands

To check linting:

poetry run flake8

This project comes with a tool called pre-commit that checks if your code is correctly linted. If you want to use it, run the following

pre-commit install

Contribute

Wanna help ? Find a bug ?

  1. Do not hesitate to fork the repository and send PRs with your changes
  2. No time to code ? Send a bug/feature issue here