Skip to main content

A (quite) simple that helps creating on-the-fly Mermaid diagrams

Project description

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:

  • keeping up-to-date diagrams about systems that can can be discovered with automated scripts :
    • architecture of a server (packages, services,...)
    • architecture of a folder (files and subfolders,...)
  • keeping up-to-date diagrams about a data-visualization tool (like Metabase, Lightdash etc.)
    • list of collections and indicators with their links for modification

❌ Do not use this module for

  • making a single instance diagram that doesn't need to be updated : documentation, presentation etc.

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 TD
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

  • All features of flowchart
    • Chart title
    • Nodes shapes
    • Links between nodes
    • Subgraph
      • Links between nodes with subgraphs
      • Directions (#24)
    • Interaction
    • Styling and classes (#19 and #20)
    • Basic support for fontawesome (#23)

November 2023

  • Main Features of stateflow-v2
    • Nodes
    • Notes
    • Start and End nodes
    • Named links between nodes
    • Graph configuration

End 2023

  • Architecture improvements for easing diagram creation

Development

  • Requirements: install Poetry. Here is the official method below. ⚠️ Please consider getting a look at Poetry's documentation if it doesn't work. ⚠️
curl -sSL https://install.python-poetry.org | python3 -
  • All-in-one command below to clone and install dependencies
curl -sSL https://install.python-poetry.org | python3 -
git clone https://github.com/Dynnammo/python_mermaid
cd python_mermaid
poetry shell
poetry install --with dev

Quick commands

  • Launch tests: poetry run pytest
  • Check linting: poetry run ruff check .
  • Check typing: poetry run mypy python_mermaid

To check linting:
```shell
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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_mermaid-0.1.5.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_mermaid-0.1.5-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file python_mermaid-0.1.5.tar.gz.

File metadata

  • Download URL: python_mermaid-0.1.5.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Linux/6.12.28-1-MANJARO

File hashes

Hashes for python_mermaid-0.1.5.tar.gz
Algorithm Hash digest
SHA256 f659cf2eb2bcd6074ea36203b199e7ac0541c63b221cb98427c4ed596c81ff15
MD5 c0701e3ea7a2403468608e848a52a52f
BLAKE2b-256 d6010f399e44ddb61424b3aaa1906591956bac026fb400343b1c18c341f9d571

See more details on using hashes here.

File details

Details for the file python_mermaid-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: python_mermaid-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Linux/6.12.28-1-MANJARO

File hashes

Hashes for python_mermaid-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 53cd3b4b7f6a3bc5964303d2a2b3d9261db2249a555f4865d7a12229ad7465ff
MD5 fd36dd873d62ec77692cad7502bad393
BLAKE2b-256 d185da74d66ad800058c285e87e77bad1645e0e0edb7ba76c4bba5d89d182501

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page