Skip to content

Commit

Permalink
feat: parse __init__.py files in packages. Closes: #52 (#76)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
JustKiddingCode authored and lucsorel committed Dec 30, 2023
1 parent b1c6c8b commit 65a1804
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 180 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ poetry run pytest -v --cov=py2puml --cov-branch --cov-report term-missing --cov-

# Changelog

* `upcoming`: replaced yapf by the ruff formatter
* `0.8.2`: add classes defined in `__init__.py` files to plantuml output
* `0.9.0`: add classes defined in `__init__.py` files to plantuml output; replaced yapf by the ruff formatter
* `0.8.1`: delegated the grouping of nested namespaces (see `0.7.0`) to the PlantUML binary, which handles it natively
* `0.8.0`: added support for union types, and github actions (pre-commit hooks + automated tests)
* `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)
Expand Down
329 changes: 156 additions & 173 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion py2puml/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def run():

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

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

Expand Down
4 changes: 4 additions & 0 deletions py2puml/inspection/inspectpackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
def inspect_package(
domain_path: str, domain_module: str, domain_items_by_fqn: Dict[str, UmlItem], domain_relations: List[UmlRelation]
):
# inspects the package module first, then its children modules and subpackages
item_module = import_module(domain_module)
inspect_module(item_module, domain_module, domain_items_by_fqn, domain_relations)

for _, name, is_pkg in walk_packages([domain_path], f'{domain_module}.'):
if not is_pkg:
domain_item_module: ModuleType = import_module(name)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "py2puml"
version = "0.8.2"
version = "0.9.0"
description = "Generate PlantUML class diagrams to document your Python application."
keywords = ["class diagram", "PlantUML", "documentation", "inspection", "AST"]
readme = "README.md"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@startuml tests.modules.withpkginitandmodule
!pragma useIntermediatePackages false

class tests.modules.withpkginitandmodule.test.InTestModule {
class tests.modules.withpkginitandmodule.InInitTest {
test_member: str
}
class tests.modules.withpkginitandmodule.InInitTest {
class tests.modules.withpkginitandmodule.test.InTestModule {
test_member: str
}
footer Generated by //py2puml//
Expand Down
2 changes: 1 addition & 1 deletion tests/py2puml/test__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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


# Description also output in the CLI
Expand Down

0 comments on commit 65a1804

Please sign in to comment.