Skip to main content

Mermaid diagram generator for Python code.

Project description

pymermaider

Ruff image image Actions status image

pymermaider is a tool written in Rust designed to generate mermaid.js class diagrams from Python code. By analyzing Python code, pymermaider automatically generates mermaid.js-compatible diagrams that represent the class structures, including classes, methods, attributes, and their relationships. This tool aims to simplify the documentation process for Python projects, making it easier to visualize class hierarchies and relationships.

Features

  • Automatic Class Diagram Generation: Generate detailed class diagrams from Python codebases with minimal configuration.
  • Mermaid.js Compatibility: Outputs diagrams in mermaid.js markdown syntax, ready to be embedded in your markdown documents or rendered using mermaid.js tools. GitHub supports this natively as you'll see below!

Installation

pymermaider is available on PYPI:

# With pip.
pip install pymermaider

# With pipx.
pipx install pymermaider

Usage

pymermaider [OPTIONS] <PATH>

Arguments

  • <PATH> The path to a file or directory to process.

Options

  • -m, --multiple-files When processing a directory, this option will generate an individual Mermaid file for each file within the directory.

  • -o, --output-dir <OUTPUT> Specify the output directory for the generated Mermaid files. Defaults to ./output if not provided.

  • -h, --help Display help information for the command.

  • -V, --version Show the current version of pymermaider.

File Selection:

  • --exclude <FILE_PATTERN>: Excludes specific files and/or directories from being analyzed.
  • --extend-exclude <FILE_PATTERN>: Similar to --exclude, but adds additional files and directories to exclude on top of those already specified.

Example for --extend-exclude:

pymermaider /path/to/dir --extend-exclude "**/tests/*,**/docs/*"

This command will exclude any folders within the subdirectories of /path/to/dir that are named tests or docs.


NOTES:

  • Some codebases are so massive that processing the directory into one file will result in mermaid code that's too large to render. By default, it's 50,000 characters. This is a good reason for the -m flag. You can break class diagrams apart more easily into multiple renderings.

Example

Given a Python file example.py with the following content:

class Animal:
    def __init__(self, name: str) -> None:
        self.name = name

class Dog(Animal):
    def bark(self) -> str:
        return "Woof!"

Running pymermaider on this file will provide:

classDiagram
    class Animal {
        - __init__(self, name) None
    }

    class Dog {
        + bark(self) str
    }

    Dog --|> Animal

Future Additions

  • Output directory option
  • Better output file naming convention
  • Import resolution (sorta-kinda implemented now, but not good enough or even used yet)
  • More language support, maybe?? 😳🤔
  • Sort classes with relationships to be grouped together
  • Test suites!

Known Issues

  • methods with property-setter decorators can be confusing in the output

Contributing

Contributions are more than welcome, just make a PR and we'll go from there!

License

This project is licensed under the MIT license. Please see the LICENSE file for more details.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pymermaider-0.1.4-py3-none-win_arm64.whl (1.6 MB view details)

Uploaded Python 3 Windows ARM64

pymermaider-0.1.4-py3-none-win_amd64.whl (1.7 MB view details)

Uploaded Python 3 Windows x86-64

pymermaider-0.1.4-py3-none-win32.whl (1.6 MB view details)

Uploaded Python 3 Windows x86

pymermaider-0.1.4-py3-none-musllinux_1_2_x86_64.whl (1.8 MB view details)

Uploaded Python 3 musllinux: musl 1.2+ x86-64

pymermaider-0.1.4-py3-none-musllinux_1_2_i686.whl (1.8 MB view details)

Uploaded Python 3 musllinux: musl 1.2+ i686

pymermaider-0.1.4-py3-none-musllinux_1_2_armv7l.whl (1.8 MB view details)

Uploaded Python 3 musllinux: musl 1.2+ ARMv7l

pymermaider-0.1.4-py3-none-musllinux_1_2_aarch64.whl (1.8 MB view details)

Uploaded Python 3 musllinux: musl 1.2+ ARM64

pymermaider-0.1.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ x86-64

pymermaider-0.1.4-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl (2.3 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ s390x

pymermaider-0.1.4-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.9 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ppc64le

pymermaider-0.1.4-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl (2.0 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ppc64

pymermaider-0.1.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (1.8 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ i686

pymermaider-0.1.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.8 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

pymermaider-0.1.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.8 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

pymermaider-0.1.4-py3-none-macosx_10_12_x86_64.whl (1.8 MB view details)

Uploaded Python 3 macOS 10.12+ x86-64

pymermaider-0.1.4-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (3.4 MB view details)

Uploaded Python 3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

File details

Details for the file pymermaider-0.1.4-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for pymermaider-0.1.4-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 07105fc9be39530658bfe5ff388546f30b8871195b77099abceaa6ed332b3609
MD5 7ac7f5371e27bd1a20eee6cbe93fcbb4
BLAKE2b-256 b58b30235d714099d8b70116632a0b019db64a52472005feee00d54811521642

See more details on using hashes here.

File details

Details for the file pymermaider-0.1.4-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for pymermaider-0.1.4-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c4e188545d9f0e81ce8acc41820186f148ee673b8e8dd8fea6ebd42eff46b2ca
MD5 3d2d5d042376c278cb2b66742a0850f2
BLAKE2b-256 b054a9f1c9db1e107a9d310ce6a744418fd75257e7e66333c92d722b1f755f12

See more details on using hashes here.

File details

Details for the file pymermaider-0.1.4-py3-none-win32.whl.

File metadata

File hashes

Hashes for pymermaider-0.1.4-py3-none-win32.whl
Algorithm Hash digest
SHA256 437e2d09dc0420d56cf51cd6ee3c2a2e9553b3bfab69910188d429f909bd7549
MD5 f9bf71c93488dd9488a385618ad7353e
BLAKE2b-256 f4d02483597326e68ebc6c75a17dbc53fe697e97e346d6889fbdd41826864d35

See more details on using hashes here.

File details

Details for the file pymermaider-0.1.4-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pymermaider-0.1.4-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d89ff2e89a8766bcfc99b490ec90d2604e06f1e202df61842204a1d43361e6fd
MD5 6f3eaf71c8ad1dfbabda3faccf8a8665
BLAKE2b-256 89eb5e41ad84d617c147dc2a82681f7549f5f349fd1953c27403ad27ca4b25d2

See more details on using hashes here.

File details

Details for the file pymermaider-0.1.4-py3-none-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for pymermaider-0.1.4-py3-none-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 1cd323ede5472c400e6120c84d268e75d16ae87dce96fc6b7d51f7df1e9def4d
MD5 5a79d4240a3706ea9012aa0e1139df67
BLAKE2b-256 2eaae660644b4474a9e0d38a803fc819f0a88904749999a3f91d4d931cc822ee

See more details on using hashes here.

File details

Details for the file pymermaider-0.1.4-py3-none-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for pymermaider-0.1.4-py3-none-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 88b110e85bfd8f0126c86a9d1c89fb699264708ee587aa72dc7bc330691bec42
MD5 7aaadb63ba9ead041e3102d9b96cf55e
BLAKE2b-256 f35e88deea64df300cc06bc276193898a4a2ec342ce24f64d58e61b9633e759c

See more details on using hashes here.

File details

Details for the file pymermaider-0.1.4-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pymermaider-0.1.4-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 db97bf5440bce1eefc8acf9df83f19a9f1432973d45ded638541fa0c95f17a24
MD5 fb6035b1b903577f484c46de7354a398
BLAKE2b-256 cb57fe7bba30ec423975b69bc9367d62a30cc491ca45c33a947be2393ab3d2c7

See more details on using hashes here.

File details

Details for the file pymermaider-0.1.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pymermaider-0.1.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 915373cd52f179d712c2083a89be591feafbf85818108760a87a2f49ffd6d3d5
MD5 6c2aff1b34a2f992d2063690f6c9ec63
BLAKE2b-256 b93bb1278cf5c0c9df19ded9c6c96d6e289d58d07290fb24ae898dec287e3084

See more details on using hashes here.

File details

Details for the file pymermaider-0.1.4-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for pymermaider-0.1.4-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 bc747da154ffd6401b3ff9c3eb977bf7f592d8a5854ed4ae31329db538ee7f45
MD5 2afa8d820dacc1b84095f2ff8fa89ca1
BLAKE2b-256 ba4dd195668810e656f825765748d3ea71c6d952c4d437a8cb7e027b5707b884

See more details on using hashes here.

File details

Details for the file pymermaider-0.1.4-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for pymermaider-0.1.4-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 f5430dabd04da308ce74202a6b8c91ffc5e83f03e04de65b297fda33230e9c9c
MD5 9b0e886357dee19f0486ca1775aa11cd
BLAKE2b-256 f15b4857cb094d65c83ac1b5f027c8a507d04b541f11ff83a45b39e4fca4f955

See more details on using hashes here.

File details

Details for the file pymermaider-0.1.4-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl.

File metadata

File hashes

Hashes for pymermaider-0.1.4-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl
Algorithm Hash digest
SHA256 60709e39394ee74666168f2719c567b74b31d6288187214760b3259723e8f5e4
MD5 0613392f425ddb02de447a85e06419c7
BLAKE2b-256 42cc7e835e46a0ab2d04bba519f8ebae923776e6b602940ab1a7ae12acd1e5fb

See more details on using hashes here.

File details

Details for the file pymermaider-0.1.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for pymermaider-0.1.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 6e44dcc4a6bb6fe36d808326c44152cb50c3a75fc2fc0842d3e650c940deb0c1
MD5 7ea6d67af176c9c7bc4d03ad77b3f011
BLAKE2b-256 ecb88359f1fe13c8898591496f81207468824121b71584d2a57a734feb78e57e

See more details on using hashes here.

File details

Details for the file pymermaider-0.1.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for pymermaider-0.1.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 18d962fae6159d0a49a47aea255ffbd041fb5f93585dacb681118c0f3514ee48
MD5 0f211510ca24bed92cad11c3a331290e
BLAKE2b-256 478b7f9f6924978265e03f116d3394e900a16d2653ee240262c2c4b066eb84dc

See more details on using hashes here.

File details

Details for the file pymermaider-0.1.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pymermaider-0.1.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d7411cdbe99a940e4f6e19db3fa282974b230541b458a4f0395ebd5a256d7e50
MD5 1b1c234dd69a7bef7f0624cb75c5f996
BLAKE2b-256 da2f0e53f06053c838350d692f9faea498411d89b1f1428eac4db7dde04cbe5d

See more details on using hashes here.

File details

Details for the file pymermaider-0.1.4-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pymermaider-0.1.4-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 16adb6e941198a81d00f21078265fde6854b87c09ebcc476ff282b50a01817e1
MD5 daf694cb3afdd0a2ea2e2453e262c464
BLAKE2b-256 d08b3a4e954265c3caf8d0a4c012ac252cf6bf131f32c0cd63bdd7bc1fd9382b

See more details on using hashes here.

File details

Details for the file pymermaider-0.1.4-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for pymermaider-0.1.4-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 4d43e690bc51d588796b65a128fedcb50baf97115abda7470d09b7cec7428077
MD5 4f69119bec48ae8c6c273da2634795f7
BLAKE2b-256 ad461cbf33455ab78ba8055dae130ed0f84edfa6787db6960c1066104c07c86c

See more details on using hashes here.

Supported by

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