14. ツール:Pyreverse#
pylint と同時にインストールされる pyrevese コマンドを使うことで、Pythonのpackageのクラス図やモジュールの関係図(パッケージ図)を生成できます。 pyrevese は、既定の設定ではgraphviz/dotなどを使ってこれらのクラス図/パッケージ図を作成しますが、PlantUMLを用いてこれららの 図を作成することができます。 PlantUMLの形式で図を作成するには、コマンドオプションに -o puml を追加します。
14.1. pyreserveのインストール#
prreserveはPyLintと一緒にインストールされます。PyLint はPIPでインストールするのが簡単です。
python3 -m pip install pylint
14.2. pyreverse コマンドの使い方#
pyreverseコマンのヘルプメッセージ
- pyreverse
Base class providing common behaviour for pyreverse commands.
usage: pyreverse [options]
Create UML diagrams for classes and modules in <packages>.
- optional arguments:
- -h, --help#
show this help message and exit
- --filter-mode <mode>, -f <mode>#
filter attributes and functions according to <mode>. Correct modes are : 'PUB_ONLY' filter all non public attributes [DEFAULT], equivalent to PRIVATE+SPECIAL_A 'ALL' no filter 'SPECIAL' filter Python special functions except constructor 'OTHER' filter protected and private attributes (default: PUB_ONLY)
- --class <class>, -c <class>#
create a class diagram with all classes related to <class>; this uses by default the options -ASmy (default: [])
- --show-ancestors <ancestor>, -a <ancestor>#
show <ancestor> generations of ancestor classes not in <projects> (default: None)
- --all-ancestors, -A#
show all ancestors off all classes in <projects> (default: None)
- --show-associated <association_level>, -s <association_level>#
show <association_level> levels of associated classes not in <projects> (default: None)
- --all-associated, -S#
- show recursively all associated off all associated classes
(default: None)
- --show-builtin, -b#
include builtin objects in representation of classes (default: False)
- --module-names <y or n>, -m <y or n>#
include module name in representation of classes (default: None)
- --only-classnames, -k#
don't show attributes and methods in the class boxes; this disables -f values (default: False)
- --output <format>, -o <format>#
create a *.<format> output file if format is available. Available formats are: dot, vcg, puml, plantuml, mmd, html. Any other format will be tried to create by means of the 'dot' command line tool, which requires a graphviz installation. (default: dot)
- --colorized#
Use colored output. Classes/modules of the same package get the same color. (default: False)
- --max-color-depth <depth>#
Use separate colors up to package depth of <depth> (default: 2)
- --ignore <file[,file...]>#
Files or directories to be skipped. They should be base names, not paths. (default: ('CVS',))
- --project <project name>, -p <project name>#
set the project name. (default: )
- --output-directory <output_directory>, -d <output_directory>#
set the output directory path. (default: )