Generator to create mermaid class diagrams.
Project description
MermaidGenerator
Automatically generate Mermaid class diagrams from Python source code.
MermaidGenerator parses your Python files using the AST and produces a Markdown file with embedded Mermaid class diagrams — no runtime execution required. See an example output.
Made by Fabian Gnatzig in 2026.
Features
- Class attributes with type annotations
- Method signatures including argument types and return types
- Inheritance relationships with links between diagrams
@staticmethodand@classmethod— marked with$@abstractmethod— marked with*@property— rendered as a typed attribute, backing field suppressed- Abstract base classes (
ABC) — rendered with<<abstract>>stereotype @dataclassand other decorators — rendered as Mermaid stereotypes- Public (
+) and private (-) visibility based on naming convention - Union types (
X | Y), generics (list[str]), and qualified types (typing.Optional) - Works on single files or entire project trees
Installation
pip install mermaidgenerator
Usage
python -m mermaidgenerator --src-folder <path> [--doc-path <output>]
| Argument | Required | Description |
|---|---|---|
--src-folder |
yes | Root directory of your Python project to scan |
--doc-path |
no | Output path for the .md file (default: <src-folder>/../class_diagrams.md) |
--exclude |
no | Glob pattern of files to skip, relative to --src-folder (can be repeated) |
Examples
# Basic usage
python -m mermaidgenerator --src-folder src --doc-path docs/class_diagrams.md
# Exclude test files and a specific module
python -m mermaidgenerator --src-folder src --exclude "**/test_*.py" --exclude "migrations/*.py"
Example output
Given a class like this:
from abc import ABC, abstractmethod
class Shape(ABC):
"""Abstract base class for shapes."""
def __init__(self, color: str) -> None:
self.color: str = color
@abstractmethod
def area(self) -> float: ...
@staticmethod
def describe(color: str) -> str: ...
MermaidGenerator produces:
# Shape
Abstract base class for shapes.
```mermaid
classDiagram
class Shape {
<<abstract>>
+ str color
- __init__(color: str) None
+ area() float *
+ describe(color: str) str $
}
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mermaidgenerator-1.2.0.tar.gz.
File metadata
- Download URL: mermaidgenerator-1.2.0.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8507c80956933037e47fc2188501a44ba43e674ec9b9f5cde1791419c2893751
|
|
| MD5 |
1e76e52ce38b5cf761035697f25df51f
|
|
| BLAKE2b-256 |
50c7adf9f291b2472c0cd467d623ef445c8d7e2e037e08b365f52d15e1deac6d
|
Provenance
The following attestation bundles were made for mermaidgenerator-1.2.0.tar.gz:
Publisher:
publish.yaml on FabianGnatzig/MermaidGenerator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mermaidgenerator-1.2.0.tar.gz -
Subject digest:
8507c80956933037e47fc2188501a44ba43e674ec9b9f5cde1791419c2893751 - Sigstore transparency entry: 1271517682
- Sigstore integration time:
-
Permalink:
FabianGnatzig/MermaidGenerator@5ce2c082d8ebe32c962820bdc0d1089a7a93bf4c -
Branch / Tag:
refs/tags/1.2.0 - Owner: https://github.com/FabianGnatzig
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@5ce2c082d8ebe32c962820bdc0d1089a7a93bf4c -
Trigger Event:
push
-
Statement type:
File details
Details for the file mermaidgenerator-1.2.0-py3-none-any.whl.
File metadata
- Download URL: mermaidgenerator-1.2.0-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fa1f136810c6c4ffebb90290f4dc5d962a65f17842776d4f76841f441ae992a
|
|
| MD5 |
b0eb45eec2e6034303b5652aa63397bb
|
|
| BLAKE2b-256 |
96b2d3b2081ef8ae9144bc9d59d48b315f852b8143f63e04b7626b4518055bce
|
Provenance
The following attestation bundles were made for mermaidgenerator-1.2.0-py3-none-any.whl:
Publisher:
publish.yaml on FabianGnatzig/MermaidGenerator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mermaidgenerator-1.2.0-py3-none-any.whl -
Subject digest:
0fa1f136810c6c4ffebb90290f4dc5d962a65f17842776d4f76841f441ae992a - Sigstore transparency entry: 1271517689
- Sigstore integration time:
-
Permalink:
FabianGnatzig/MermaidGenerator@5ce2c082d8ebe32c962820bdc0d1089a7a93bf4c -
Branch / Tag:
refs/tags/1.2.0 - Owner: https://github.com/FabianGnatzig
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@5ce2c082d8ebe32c962820bdc0d1089a7a93bf4c -
Trigger Event:
push
-
Statement type: