Skip to main content

No project description provided

Project description

MermaidGenerator

Automatically generate Mermaid class diagrams from Python source code.

PyPI version Python License

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
  • @staticmethod and @classmethod — marked with $
  • @abstractmethod — marked with *
  • @property — rendered as a typed attribute, backing field suppressed
  • Abstract base classes (ABC) — rendered with <<abstract>> stereotype
  • @dataclass and 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


Download files

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

Source Distribution

mermaidgenerator-1.1.0.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

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

mermaidgenerator-1.1.0-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file mermaidgenerator-1.1.0.tar.gz.

File metadata

  • Download URL: mermaidgenerator-1.1.0.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mermaidgenerator-1.1.0.tar.gz
Algorithm Hash digest
SHA256 c1149f2b00b994a214d983e32ae46c7ad4277d06745a1878c4d496a7bbcc89f5
MD5 5ba43c87b5fff6419523e74fb851c87d
BLAKE2b-256 0f9532ad35bb804a8730d58292b03d9b6b15cb51d6910f1c253e5075f9008814

See more details on using hashes here.

Provenance

The following attestation bundles were made for mermaidgenerator-1.1.0.tar.gz:

Publisher: publish.yaml on FabianGnatzig/MermaidGenerator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mermaidgenerator-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mermaidgenerator-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9be5d0a2a01139844d2451b2f258780d1ca85eb73fba8fdbd321f0520ee403a2
MD5 34c699d16ecaaf2c42a932214ee5ec38
BLAKE2b-256 f5d44b6ee3ed503fc3235a00bc65ab19695c56cddc0858ba48ff1728e2b3a4b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for mermaidgenerator-1.1.0-py3-none-any.whl:

Publisher: publish.yaml on FabianGnatzig/MermaidGenerator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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