Mermaid diagram generator for Python code.
Project description
pymermaider
Try the online pymermaider playground! powered by WebAssembly 🎉
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>Path to a file or directory. Use '-' to read Python source from stdin.
Options
-
-m, --multiple-filesProcess each file individually, outputting a mermaid file for each file. Only used when path is a directory. -
-o, --output-dir <OUTPUT>Output directory for mermaid files. [default: ./output] -
--output-format <OUTPUT_FORMAT>Output file format. [default: md] [possible values: md, mmd]mmdmay become the default in the future, depending on user feedback
-
--output <OUTPUT>Output file path. Use '-' to write to stdout. Not compatible with--multiple-files. -
-h, --helpDisplay help information for the command. -
-V, --versionShow the current version ofpymermaider.
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.
Export raw Mermaid to .mmd:
pymermaider /path/to/dir --output-dir ./output --output-format mmd
I/O Examples
# py file -> stdout
pymermaider my_file.py --output -
# stdin -> stdout
cat my_file.py | pymermaider - --output -
# py file -> file (raw Mermaid)
pymermaider my_file.py --output-format mmd --output diagram.mmd
# directory -> stdout (single combined diagram)
pymermaider ./my_project --output - > diagram.md
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
-mflag. 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
- Import/type resolution powered by ty
- More language support, maybe?? 😳🤔
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
Built Distributions
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 pymermaider-0.1.6-py3-none-win_arm64.whl.
File metadata
- Download URL: pymermaider-0.1.6-py3-none-win_arm64.whl
- Upload date:
- Size: 2.0 MB
- Tags: Python 3, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f03d411aae3c0e7e221165d670eff2dcbe63e6ecc5af5c424bf9ca859cf5d01
|
|
| MD5 |
52db77391a886ced3be918a6046957db
|
|
| BLAKE2b-256 |
3e6a09fcb76aee008a65a8c1fa2f47171baabe0ce68b7da1ebb54839260560a9
|
File details
Details for the file pymermaider-0.1.6-py3-none-win_amd64.whl.
File metadata
- Download URL: pymermaider-0.1.6-py3-none-win_amd64.whl
- Upload date:
- Size: 2.1 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a77ceb982ebb685eb11209b84340af5cea8d83de6876f7dc86b222d617e5f61
|
|
| MD5 |
e861273e75b2b8c19c98c27d7d98c159
|
|
| BLAKE2b-256 |
c41d4d27f47e6ec5dd63b17bdba0b5c0d7641dd591c6f3335f0cfc213285e8bd
|
File details
Details for the file pymermaider-0.1.6-py3-none-win32.whl.
File metadata
- Download URL: pymermaider-0.1.6-py3-none-win32.whl
- Upload date:
- Size: 1.9 MB
- Tags: Python 3, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eedf8d26b0a21ad60d09af0d625c93d8cd78800ed7f14be1f0b303dc9a75b565
|
|
| MD5 |
23d6cdebe9bbb5a8af81674adb3daf10
|
|
| BLAKE2b-256 |
0f2fa51742258631f3a3b8b4b452d843cda14a95022636c04a7705a39e976cc6
|
File details
Details for the file pymermaider-0.1.6-py3-none-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: pymermaider-0.1.6-py3-none-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: Python 3, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d2c1692b09f8bf05fbfc0236355866c75e00a3db29cbd599aa08f34462586f6
|
|
| MD5 |
60da032dd20c998b3af4aefbb0a2b4c9
|
|
| BLAKE2b-256 |
694def49ef341e29806c7824f72f511e1f7422dfb6b26d73c5d2f2500fbc562e
|
File details
Details for the file pymermaider-0.1.6-py3-none-musllinux_1_2_i686.whl.
File metadata
- Download URL: pymermaider-0.1.6-py3-none-musllinux_1_2_i686.whl
- Upload date:
- Size: 2.1 MB
- Tags: Python 3, musllinux: musl 1.2+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2257055422aaa798aa40c868b65525f1f93df6cb08beb1d49b78aa405479e6e
|
|
| MD5 |
f5ec6d22eebdfd6aa5c9378a31fa1e03
|
|
| BLAKE2b-256 |
ca24a65fde187d4c283535e6abe2927886be703af133f95417fe989c9c4a5da7
|
File details
Details for the file pymermaider-0.1.6-py3-none-musllinux_1_2_armv7l.whl.
File metadata
- Download URL: pymermaider-0.1.6-py3-none-musllinux_1_2_armv7l.whl
- Upload date:
- Size: 2.0 MB
- Tags: Python 3, musllinux: musl 1.2+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a187d3c026d5262bba0f9cc299fbe27af768416c3d0ebda40dabb17130d132ba
|
|
| MD5 |
701dd633ff1c1ce31812c86cf9e742d4
|
|
| BLAKE2b-256 |
43fae92661c51170e2662965f88ce94716a71094531f507914d0be813390b8a1
|
File details
Details for the file pymermaider-0.1.6-py3-none-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: pymermaider-0.1.6-py3-none-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 2.0 MB
- Tags: Python 3, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5145da900032ea319976eaf39c907519dd47a03b4f0d9325045d527891604afd
|
|
| MD5 |
c0f57078f10fcc9400d9bd429a61444a
|
|
| BLAKE2b-256 |
ae8788cdc113dd6903d710146848a7ed19412568054f9e452fb4fb46c7da79c2
|
File details
Details for the file pymermaider-0.1.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pymermaider-0.1.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.1 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
677027348574c89d5de7701698a56f6ef0277ffaa9c6f00b390caaf11ab9648d
|
|
| MD5 |
3de05f1d85e326c99aea14c26f0dc8d7
|
|
| BLAKE2b-256 |
55cb52ff884c418dcbf5f97db2f49c5f5a00ab7a29acc10f4bb6fc14a92a38ed
|
File details
Details for the file pymermaider-0.1.6-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl.
File metadata
- Download URL: pymermaider-0.1.6-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 2.2 MB
- Tags: Python 3, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbfe36dd41842a01d6cd71645b1231d9a2dddb6004155a8d5af9173d86595155
|
|
| MD5 |
a52ac717099c35d1a49ecba2c7ca2ebf
|
|
| BLAKE2b-256 |
f0a9a3a6931c4fde06db59712ac7807be37a69fbf0b025391868e511a8b46186
|
File details
Details for the file pymermaider-0.1.6-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.
File metadata
- Download URL: pymermaider-0.1.6-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 2.2 MB
- Tags: Python 3, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ceadc05ba54beaf856275ad3f37a4d8d970829a6f64b4f7c60b3075a8bd06a9
|
|
| MD5 |
3c6afead8c18b460443e8873e04b315f
|
|
| BLAKE2b-256 |
fc4de0b7d40eff409a235ada43f38fdebb2d582956e1b1ebe9a4cec06371e28a
|
File details
Details for the file pymermaider-0.1.6-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl.
File metadata
- Download URL: pymermaider-0.1.6-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl
- Upload date:
- Size: 2.2 MB
- Tags: Python 3, manylinux: glibc 2.17+ ppc64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
297050894bc901e21ea571be271f4c056b5f6664e0715e3e50dc7f4d4ebdf36e
|
|
| MD5 |
2caff2db684e57e7257796aa42437982
|
|
| BLAKE2b-256 |
9eeb4e001b0621f6898343c46aa19b2bc5bd4c76ce848ec0ac173c0da4d0f39c
|
File details
Details for the file pymermaider-0.1.6-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: pymermaider-0.1.6-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 2.1 MB
- Tags: Python 3, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
621eca3c4edb7922f48654cb7c858fa905b3f362e7932b58cb713c327207c63b
|
|
| MD5 |
7433cc98db83e195b3bac1bd6effdb7b
|
|
| BLAKE2b-256 |
566f4d166d963f536d00ed3745caa102d0221363473330b45a1f9133cff37f68
|
File details
Details for the file pymermaider-0.1.6-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: pymermaider-0.1.6-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 2.0 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f9a1f424d2b595e185e0f182b21504be0df606b7c35ae75f75b781d0a14b020
|
|
| MD5 |
847a1c847ae8a8e0e398894314822095
|
|
| BLAKE2b-256 |
f7849f7bdac92eadf8645275d33f565b65b90ab5372f4fd2b912db52337c32b0
|
File details
Details for the file pymermaider-0.1.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pymermaider-0.1.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.0 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36aeb5a3003451121129d5b6026f4087d78604761f8e014edd6aed795d043ed2
|
|
| MD5 |
870ea09ea3df99e25209353de563dc4f
|
|
| BLAKE2b-256 |
bfd8cdab501efb868c4eb7545a56d5ed3e888239bf79220811e019a479f74983
|
File details
Details for the file pymermaider-0.1.6-py3-none-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pymermaider-0.1.6-py3-none-macosx_10_12_x86_64.whl
- Upload date:
- Size: 2.0 MB
- Tags: Python 3, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2d58663e3abb001c540e00d8699dd0f4fc3e9e8479998730a74e9f566ac885a
|
|
| MD5 |
18a2c697328534d643a11a7a140b43b0
|
|
| BLAKE2b-256 |
7141244080105e131c0646ddcac87138c91940cceb5899e6879f714561c5beca
|
File details
Details for the file pymermaider-0.1.6-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.
File metadata
- Download URL: pymermaider-0.1.6-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 4.0 MB
- Tags: Python 3, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49339b433b4a216c4fc53787127703eb5809c543e3901f4166e94bb606f6a998
|
|
| MD5 |
8491d3a8d846b55be2b87d67ac8c40b5
|
|
| BLAKE2b-256 |
bd8238028d65f8097e8fc59da3e13173d32147d1cfaf7a2e5dec4b1d2dd59304
|