Skip to content

Commit 739740b

Browse files
vignesh14052002vignesharivazhagan
authored andcommitted
Expose controls on which block, method, relation can be included in diagram
1 parent 5d02050 commit 739740b

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

py2puml/export/puml.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@
2626
FEATURE_INSTANCE = ''
2727

2828

29-
def to_puml_content(diagram_name: str, uml_items: List[UmlItem], uml_relations: List[UmlRelation]) -> Iterable[str]:
29+
def to_puml_content(
30+
diagram_name: str, uml_items: List[UmlItem], uml_relations: List[UmlRelation], **kwargs
31+
) -> Iterable[str]:
3032
yield PUML_FILE_START.format(diagram_name=diagram_name)
3133

3234
# exports the domain classes and enums
3335
for uml_item in uml_items:
36+
if 'is_block_valid' in kwargs and callable(kwargs['is_block_valid']) and not kwargs['is_block_valid'](uml_item):
37+
continue
3438
if isinstance(uml_item, UmlEnum):
3539
uml_enum: UmlEnum = uml_item
3640
yield PUML_ITEM_START_TPL.format(item_type='enum', item_fqn=uml_enum.fqn)
@@ -48,12 +52,27 @@ def to_puml_content(diagram_name: str, uml_items: List[UmlItem], uml_relations:
4852
attr_type=uml_attr.type,
4953
staticity=FEATURE_STATIC if uml_attr.static else FEATURE_INSTANCE,
5054
)
55+
for uml_method in uml_class.methods:
56+
if (
57+
'is_method_valid' in kwargs
58+
and callable(kwargs['is_method_valid'])
59+
and not kwargs['is_method_valid'](uml_method)
60+
):
61+
continue
62+
63+
yield f' {uml_method.represent_as_puml()}\n'
5164
yield PUML_ITEM_END
5265
else:
5366
raise TypeError(f'cannot process uml_item of type {uml_item.__class__}')
5467

5568
# exports the domain relationships between classes and enums
5669
for uml_relation in uml_relations:
70+
if (
71+
'is_relation_valid' in kwargs
72+
and callable(kwargs['is_relation_valid'])
73+
and not kwargs['is_relation_valid'](uml_relation)
74+
):
75+
continue
5776
yield PUML_RELATION_TPL.format(
5877
source_fqn=uml_relation.source_fqn, rel_type=uml_relation.type.value, target_fqn=uml_relation.target_fqn
5978
)

py2puml/py2puml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
from py2puml.inspection.inspectpackage import inspect_package
77

88

9-
def py2puml(domain_path: str, domain_module: str) -> Iterable[str]:
9+
def py2puml(domain_path: str, domain_module: str, **kwargs) -> Iterable[str]:
1010
domain_items_by_fqn: Dict[str, UmlItem] = {}
1111
domain_relations: List[UmlRelation] = []
1212
inspect_package(domain_path, domain_module, domain_items_by_fqn, domain_relations)
1313

14-
return to_puml_content(domain_module, domain_items_by_fqn.values(), domain_relations)
14+
return to_puml_content(domain_module, domain_items_by_fqn.values(), domain_relations, **kwargs)

0 commit comments

Comments
 (0)