🖼️ diagrams.sh
This script generates UML diagrams for a specified Python module using pyreverse
and code2flow
. It checks for dependencies, loads environment variables, sets directories, and processes command-line arguments for customization of module names, directories, and output locations.
Overview
The script performs the following operations:
-
Base Setup: Identifies the project and script directories, sources the
base.sh
script for utility functions, and loads environment variables from a.env
file if it exists. -
Dependency Checks: Verifies the presence of required tools:
graphviz
for.dot
file handling.python
for running Python-based commands.pylint
(withpyreverse
) for generating UML diagrams.code2flow
for creating flowcharts.
-
Environment Variable Setup: Sets default values for module name, module directory, and output directory (
MODULE_NAME
,MODULE_DIR
,OUTPUT_DIR
). These can be customized via environment variables or command-line arguments. -
Argument Parsing: Parses optional arguments to allow customization:
-m
or--module-name
to specify the module name.-d
or--module-dir
to specify the module directory.-o
or--output-dir
to specify the output directory.
-
Directory Creation: Creates subdirectories within the output directory for organizing different types of UML and flowchart outputs:
classes
for class diagrams.packages
for package diagrams.flowcharts
for code flowcharts.
-
Diagram Generation: Runs
pyreverse
to create UML diagrams in multiple formats (html
,pdf
,png
, andsvg
) and organizes them into respective directories. It also generates flowcharts withcode2flow
. -
Completion Message: Displays a message confirming successful generation of diagrams.
Usage
To run the script: