Skip to content

Commit 65a1804

Browse files
JustKiddingCodelucsorel
authored andcommitted
feat: parse __init__.py files in packages. Closes: #52 (#76)
Co-authored-by: Konstantin Zangerle <[email protected]> docs(version): set version to 0.9.0, parsing root module is a new feature Signed-off-by: Luc Sorel-Giffo <[email protected]>
1 parent b1c6c8b commit 65a1804

File tree

7 files changed

+166
-180
lines changed

7 files changed

+166
-180
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ poetry run pytest -v --cov=py2puml --cov-branch --cov-report term-missing --cov-
202202

203203
# Changelog
204204

205-
* `upcoming`: replaced yapf by the ruff formatter
206-
* `0.8.2`: add classes defined in `__init__.py` files to plantuml output
205+
* `0.9.0`: add classes defined in `__init__.py` files to plantuml output; replaced yapf by the ruff formatter
207206
* `0.8.1`: delegated the grouping of nested namespaces (see `0.7.0`) to the PlantUML binary, which handles it natively
208207
* `0.8.0`: added support for union types, and github actions (pre-commit hooks + automated tests)
209208
* `0.7.2`: added the current working directory to the import path to make py2puml work in any directory or in native virtual environment (not handled by poetry)

poetry.lock

+156-173
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

py2puml/cli.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def run():
1616

1717
argparser = ArgumentParser(description='Generate PlantUML class diagrams to document your Python application.')
1818

19-
argparser.add_argument('-v', '--version', action='version', version='py2puml 0.8.1')
19+
argparser.add_argument('-v', '--version', action='version', version='py2puml 0.9.0')
2020
argparser.add_argument('path', metavar='path', type=str, help='the filepath to the domain')
2121
argparser.add_argument('module', metavar='module', type=str, help='the module name of the domain', default=None)
2222

py2puml/inspection/inspectpackage.py

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
def inspect_package(
1212
domain_path: str, domain_module: str, domain_items_by_fqn: Dict[str, UmlItem], domain_relations: List[UmlRelation]
1313
):
14+
# inspects the package module first, then its children modules and subpackages
15+
item_module = import_module(domain_module)
16+
inspect_module(item_module, domain_module, domain_items_by_fqn, domain_relations)
17+
1418
for _, name, is_pkg in walk_packages([domain_path], f'{domain_module}.'):
1519
if not is_pkg:
1620
domain_item_module: ModuleType = import_module(name)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "py2puml"
3-
version = "0.8.2"
3+
version = "0.9.0"
44
description = "Generate PlantUML class diagrams to document your Python application."
55
keywords = ["class diagram", "PlantUML", "documentation", "inspection", "AST"]
66
readme = "README.md"

tests/modules/withpkginitandmodule/tests.modules.withpkginitandmodule.puml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
@startuml tests.modules.withpkginitandmodule
22
!pragma useIntermediatePackages false
33

4-
class tests.modules.withpkginitandmodule.test.InTestModule {
4+
class tests.modules.withpkginitandmodule.InInitTest {
55
test_member: str
66
}
7-
class tests.modules.withpkginitandmodule.InInitTest {
7+
class tests.modules.withpkginitandmodule.test.InTestModule {
88
test_member: str
99
}
1010
footer Generated by //py2puml//

tests/py2puml/test__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Ensures the library version is modified in the pyproject.toml file when upgrading it (pull request)
55
def test_version():
6-
assert __version__ == '0.8.1'
6+
assert __version__ == '0.9.0'
77

88

99
# Description also output in the CLI

0 commit comments

Comments
 (0)