-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve pyreverse documentation (#10063)
Co-authored-by: Pierre Sassoulas <[email protected]>
- Loading branch information
1 parent
a18a27f
commit 614f80e
Showing
5 changed files
with
146 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,40 @@ | ||
.. _pyreverse: | ||
|
||
========= | ||
Pyreverse | ||
--------- | ||
========= | ||
|
||
``pyreverse`` analyzes your source code and generates package and class diagrams. | ||
``pyreverse`` is a powerful tool that creates UML diagrams from your Python code. It helps you visualize: | ||
|
||
It supports output to ``.dot``/``.gv``, ``.puml``/``.plantuml`` (PlantUML) and ``.mmd``/``.html`` (MermaidJS) file formats. | ||
If Graphviz (or the ``dot`` command) is installed, all `output formats supported by Graphviz <https://graphviz.org/docs/outputs/>`_ | ||
can be used as well. In this case, ``pyreverse`` first generates a temporary ``.gv`` file, which is then | ||
fed to Graphviz to generate the final image. | ||
- Package dependencies and structure | ||
- Class hierarchies and relationships | ||
- Method and attribute organization | ||
|
||
Running Pyreverse | ||
''''''''''''''''' | ||
Output Formats | ||
============== | ||
|
||
To run ``pyreverse``, use:: | ||
``pyreverse`` supports multiple output formats: | ||
|
||
pyreverse [options] <packages> | ||
* Native formats: | ||
* ``.dot``/``.gv`` (Graphviz) | ||
* ``.puml``/``.plantuml`` (PlantUML) | ||
* ``.mmd``/``.html`` (MermaidJS) | ||
|
||
<packages> can also be a single Python module. | ||
To see a full list of the available options, run:: | ||
* Additional formats (requires Graphviz installation): | ||
* All `Graphviz output formats <https://graphviz.org/docs/outputs/>`_ (PNG, SVG, PDF, etc.) | ||
* ``pyreverse`` first generates a temporary ``.gv`` file, which is then fed to Graphviz to generate the final image | ||
|
||
pyreverse -h | ||
Getting Started | ||
=============== | ||
|
||
Example Output | ||
'''''''''''''' | ||
|
||
Example diagrams generated with the ``.puml`` output format are shown below. | ||
|
||
Class Diagram | ||
............. | ||
|
||
.. image:: ../../media/pyreverse_example_classes.png | ||
:width: 625 | ||
:height: 589 | ||
:alt: Class diagram generated by pyreverse | ||
:align: center | ||
|
||
|
||
Package Diagram | ||
............... | ||
|
||
.. image:: ../../media/pyreverse_example_packages.png | ||
:width: 344 | ||
:height: 177 | ||
:alt: Package diagram generated by pyreverse | ||
:align: center | ||
|
||
|
||
Creating Class Diagrams for Specific Classes | ||
'''''''''''''''''''''''''''''''''''''''''''' | ||
|
||
In many cases creating a single diagram depicting all classes in the project yields a rather unwieldy, giant diagram. | ||
While limiting the input path to a single package or module can already help greatly to narrow down the scope, the ``-c`` option | ||
provides another way to create a class diagram focusing on a single class and its collaborators. | ||
For example, running:: | ||
|
||
pyreverse -ASmy -c pylint.checkers.classes.ClassChecker pylint | ||
|
||
will generate the full class and package diagrams for ``pylint``, but will additionally generate a file ``pylint.checkers.classes.ClassChecker.dot``: | ||
|
||
.. image:: ../../media/ClassChecker_diagram.png | ||
:width: 757 | ||
:height: 1452 | ||
:alt: Package diagram generated by pyreverse | ||
:align: center | ||
Check out the :doc:`configuration` guide to learn about available options, or see :doc:`output_examples` | ||
for sample diagrams and common use cases. | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:hidden: | ||
:maxdepth: 2 | ||
:caption: Pyreverse | ||
:titlesonly: | ||
:hidden: | ||
|
||
configuration | ||
configuration | ||
output_examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Example Output | ||
############## | ||
|
||
Example diagrams generated with the ``.puml`` output format are shown below. | ||
|
||
Package Diagram | ||
............... | ||
|
||
.. image:: ../../media/pyreverse_example_packages.png | ||
:width: 344 | ||
:height: 177 | ||
:alt: Package diagram generated by pyreverse | ||
:align: center | ||
|
||
Class Diagram | ||
............. | ||
|
||
.. image:: ../../media/pyreverse_example_classes.png | ||
:width: 625 | ||
:height: 589 | ||
:alt: Class diagram generated by pyreverse | ||
:align: center | ||
|
||
Creating Class Diagrams for Specific Classes | ||
'''''''''''''''''''''''''''''''''''''''''''' | ||
|
||
In many cases creating a single diagram depicting all classes in the project yields a rather unwieldy, giant diagram. | ||
While limiting the input path to a single package or module can already help greatly to narrow down the scope, the ``-c`` option | ||
provides another way to create a class diagram focusing on a single class and its collaborators. | ||
For example, running:: | ||
|
||
pyreverse -ASmy -c pylint.checkers.classes.ClassChecker pylint | ||
|
||
will generate the full class and package diagrams for ``pylint``, but will additionally generate a file ``pylint.checkers.classes.ClassChecker.dot``: | ||
|
||
.. image:: ../../media/ClassChecker_diagram.png | ||
:width: 757 | ||
:height: 1452 | ||
:alt: Package diagram generated by pyreverse | ||
:align: center |
Oops, something went wrong.