lucsorel / py2puml

Generate PlantUML class diagrams to document your Python application.
https://pypi.org/project/py2puml/
MIT License
217 stars 35 forks source link

Expose controls on which block, method, relation can be included in uml diagram #108

Open vignesh14052002 opened 3 months ago

vignesh14052002 commented 3 months ago

For my usecase, I need to ignore some portions in the uml diagram whenever i was generating, thought it would be useful for others as well, so raising this PR

Usage

from py2puml.domain.umlrelation import UmlRelation
from py2puml.domain.umlclass import UmlMethod
from py2puml.domain.umlitem import UmlItem
from py2puml.export.puml import Filters
from py2puml.py2puml import py2puml

def skip_block(item: UmlItem) -> bool:
    return item.fqn.endswith('<block-to-ignore>')

def skip_relation(relation: UmlRelation) -> bool:
    return relation.source_fqn.endswith('<relation-source>') and relation.target_fqn.endswith('<relation-target>')

filters = Filters(skip_block, skip_relation)

puml_content = "".join(
        py2puml(
            'py2puml/domain',
            'py2puml.domain',
            filters
        )
    )
lucsorel commented 3 months ago

hi @vignesh14052002, thank you for your pull-request :pray:

I am lacking free time to handle the PRs on this project for the moment and there are several that should be merged first, I am sorry to keep you waiting.

However, I had a quick look at the changes that you proposed and I feel like the naming of the filtering functions that you proposed is not clear enough :thinking: since it is not a matter of "validity". I think that such functions should be called skip_block rather than "not is_block_valid". Maybe all the "skip" functions should be passed in a filtering object rather than in the kwargs.

The whole idea of filtering out unwanted contents is good though, I am just not fond of the implementation as it is now. Let's give that some time and thoughts before being merged. And the PR lacks unit tests, which is a requirement to have it merged (see https://github.com/lucsorel/py2puml/blob/main/CONTRIBUTING.md#unit-tests). It also lacks documentation in the readme.md file, but let's do that after redesigning the feature request.

vignesh14052002 commented 3 months ago

hi @lucsorel , Thank you for your feedback , made the suggested changes, added tests and docs. There’s no rush to review the PR as we have implemented the necessary changes locally and are using the builded .whl file. We will switch to the official package once this PR is merged.