Skip to content

Python Interface for the Popular mermaid-js Library, Simplified for Diagram Creation

License

Notifications You must be signed in to change notification settings

ouhammmourachid/mermaid-py

Repository files navigation

Mermaid-py

this package works as an interface for the famous mermaid-js library that uses scripts to create diagrams.

Code Coverage GitHub LICENSE Mounthly Download latest version suported python version

Description

mermaid-py is a dynamic Python library designed to serve as a seamless interface for the renowned Mermaid library. Built upon the powerful capabilities of Python, mermaid-py empowers developers and data enthusiasts to effortlessly create stunning diagrams, flowcharts, and visualizations directly within their Python environments.

Examples

first install mermaid-py by pip install mermaid-py.

  • using Mermaid and Graph classes:
import mermaid as md
from mermaid.graph import Graph

graph: Graph = Graph('example-flowchart',"""
flowchart TD
    A[Christmas] -->|Get money| B(Go shopping)
    B --> C{Let me think}
    C -->|One| D[Laptop]
    C -->|Two| E[iPhone]
    C -->|Three| F[fa:fa-car Car]
""")
graphe: md.Mermaid = md.Mermaid(graph)
graphe # !! note this work just in notbooke that render html.

the result will be like this

Example Flowchart

  • using mermaidjs magic function in a notebook first import mermaid as md:
%%mermaidjs # with --img flag in case your natebook doesn't render html
flowchart LR
    A-->B
    B-->C

the result:

Example Flowchart

  • using FlowChart etc ...
from mermaid import *
from mermaid.flowchart import *

diagram = Mermaid(Flowchart(...))

diagram

Technologies Used

  • Python3
  • Poetry

To contribute to mermaid-py

If you'd like to contribute to this open source project folow this steps:

  1. Forke the repo and then clone it.
  2. Navigate to the project directory: cd mermaid-py.
  3. create a local enviroment python3 -m venv env.
  4. activate the env source env/bin/activate.
  5. install the dependecies poetry install.
  6. happy coding :) .

List of Diagrames

License

This project is licensed under the MIT License.

Contact

If you have any questions or want to get in touch, you can reach out to me at [email protected].