You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-6Lines changed: 9 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,28 +13,30 @@ Generate Plantuml diagrams to document your python code
13
13
14
14
# How it works
15
15
16
+
## Features
17
+
16
18
From a given path corresponding to a folder containing python code, `py2puml` loads each file as a module and generate a class diagram with the [PlantUML](https://plantuml.com/en/class-diagram) using:
17
19
18
20
* inspection to detect the classes to document (see the [inspect](https://docs.python.org/3/library/inspect.html) module)
19
21
* annotations (the python type hinting syntax) to detect the attributes and their types (see the [typing](https://docs.python.org/3/library/typing.html) module)
22
+
* fields for classes derived from namedtuples
23
+
* composition and inheritance relationships are drawn only between the domain classes (this is designed on purpose, for documentation sake)
20
24
21
-
Current limitations:
25
+
## Current limitations
22
26
23
-
* type hinting is optional when writing the code and discarded when it is executed, as mentionned in the official documentation. The quality of the diagram output by `py2puml` depends on the reliability with which the annotations were written
27
+
* type hinting is optional when writing Python code and discarded when it is executed, as mentionned in the [typing official documentation](https://docs.python.org/3/library/typing.html). The quality of the diagram output by `py2puml` depends on the reliability with which the type annotations were written
24
28
25
29
> The Python runtime does not enforce function and variable type annotations. They can be used by third party tools such as type checkers, IDEs, linters, etc.
26
30
27
31
* complex type hints with more than one level of genericity are not properly handled for the moment: `List[MyClass]` or `Dict[str, MyClass]` are handled properly, `Dict[str, List[MyClass]]` is not. If your domain classes (also called business objects or DTOs) have attributes with complex type hints, it may be a code smell indicating that you should write a class which would better represent the business logic. But I may improve this part of the library as well 😀
28
32
29
-
* composition relationships are detected and drawn. Inheritance relationships are not handled for now
30
-
31
33
*`py2puml` does not inspect sub-folders recursively, but it is planned
32
34
33
35
*`py2puml` outputs diagrams in PlantUML syntax, which can be saved in text files along your python code and versioned with them. To generate image files, use the PlantUML runtime or a docker image (see [think/plantuml](https://hub.docker.com/r/think/plantuml))
34
36
35
37
*`py2puml` uses features of python 3 (generators for example) and thus won't work with python 2 runtimes. It relies on native python modules and uses no 3rd-party library, except [pytest](https://docs.pytest.org/en/latest/) as a development dependency for running the unit-tests
36
38
37
-
You may also be interested in this [lucsorel/plantuml-file-loader](https://github.com/lucsorel/plantuml-file-loader) project: A webpack loader which converts PlantUML files into images during the webpack processing (useful to [include PlantUML diagrams in your slides](https://github.com/lucsorel/markdown-image-loader/blob/master/README.md#web-based-slideshows) with RevealJS or RemarkJS).
39
+
If you like tools around PlantUML, you may also be interested in this [lucsorel/plantuml-file-loader](https://github.com/lucsorel/plantuml-file-loader) project: A webpack loader which converts PlantUML files into images during the webpack processing (useful to [include PlantUML diagrams in your slides](https://github.com/lucsorel/markdown-image-loader/blob/master/README.md#web-based-slideshows) with RevealJS or RemarkJS).
38
40
39
41
# Install
40
42
@@ -126,6 +128,7 @@ python3 -m pytest -v
126
128
127
129
# Changelog
128
130
131
+
*`0.3.0`: handle classes derived from namedtuples (attribute types are `any`)
129
132
*`0.2.0`: handle inheritance relationships and enums. Unit tested
130
133
*`0.1.3`: first release, handle all module of a folder and compositions of domain classes
131
134
@@ -142,7 +145,7 @@ Pull-requests are welcome and will be processed on a best-effort basis.
142
145
143
146
# Alternatives
144
147
145
-
If `py2puml` does not meet your needs (suggestions and pull-requests are welcome), you can have a look at these projects which follow other approaches (AST, linting, modeling):
148
+
If `py2puml` does not meet your needs (suggestions and pull-requests are **welcome**), you can have a look at these projects which follow other approaches (AST, linting, modeling):
0 commit comments