A lightweight bash tool built as a wrapper around pyreverse that automatically generates individual UML class diagrams for Python files.
- Python 3.x
- pyreverse (included in
pylintpackage)
pip install pylint- Graphviz - Required for PNG and PDF generation
Ubuntu/Debian:
sudo apt-get install graphvizmacOS:
brew install graphvizWindows:
choco install graphvizBefore installing the tool, start by cloning the GitHub repository :
git clone https://github.com/JRosierIGN/PyDUS.git
cd PyDUSTo use pydus from anywhere on your system, follow the instructions below:
Ubuntu/Debian:
# Make the script executable
chmod +x pydus.sh
# Install globally
sudo cp pydus.sh /usr/local/bin/pydusUbuntu/Debian:
# Create local bin directory if it doesn't exist
mkdir -p ~/.local/bin
# Copy and make executable
cp pydus.sh ~/.local/bin/pydus
chmod +x ~/.local/bin/pydus
# Add to PATH (add this line to ~/.bashrc or ~/.zshrc)
export PATH="$HOME/.local/bin:$PATH"
# Reload your shell configuration
source ~/.bashrc # or source ~/.zshrcWindows:
Add the script to the PATH for global access:
- Place
pydus.batin a folder, for exampleC:\Program Files\PyDus - Add this folder to your PATH environment variable:
- Open the Start menu, search for Environment Variables, and open Edit the system environment variables
- Click Environment Variables…
- In the User variables section, select Path and click Edit…
- Click New and add
C:\Program Files\PyDus - Click OK to close all windows
pydus [options] <source_directory> <output_directory> [format]-v, --verbose- Show detailed output from pyreverse during processing-h, --help- Display help message with complete documentation
source_directory- Root directory containing .py files to analyzeoutput_directory- Directory where generated diagrams will be savedformat- (Optional) Output format:svg,png,dot, orpdf(default:svg)
Generate SVG diagrams (default):
pydus ./my_project ./docs/umlGenerate PNG diagrams:
pydus ./my_project ./docs/uml pngGenerate PDF diagrams:
pydus ./my_project ./docs/uml pdfGenerate DOT files for custom processing:
pydus ./my_project ./docs/uml dotVerbose mode for debugging:
pydus -v ./my_project ./docs/uml svgGet help:
pydus --help
# or
pydus -h| Format | Extension | Description | Graphviz Required |
|---|---|---|---|
| svg | .svg |
Scalable Vector Graphics (recommended) | No |
| png | .png |
Portable Network Graphics (raster) | Yes |
.pdf |
Portable Document Format | Yes | |
| dot | .dot |
Graphviz DOT format for further processing | No |
my_project/
├── models/
│ ├── user.py # Contains User class
│ ├── product.py # Contains Product class
│ └── __init__.py # Automatically skipped
├── utils/
│ ├── helpers.py # Contains Helper class
│ └── config.py # No class - skipped
└── main.py # No class - skipped
uml_output/
├── user.svg
├── product.svg
└── helpers.svg
- Python files (
.py) containing one or more class definitions - Files in subdirectories
- All class types (regular classes, abstract classes, dataclasses, etc.)
__init__.pyfiles- Python scripts without class definitions
- Non-Python files
Each generated diagram includes:
- Class names
- Attributes with type annotations
- Methods with parameters and return types
Error: "pyreverse not found"
pip install pylintPNG/PDF generation fails
# Install Graphviz (see Requirements section)Permission denied
chmod +x pydus.shScript not found after installation
# Make sure ~/.local/bin is in your PATH
echo $PATH | grep ".local/bin"