Diagram Extension
diagram_rule
DiagramRule
Bases: FileRule
, BaseModuleSpecifier
, RuleApplier
Represents a set of architectural rules as defined in a diagram file. Reads the specified file, generates architectural rules, and returns an aggregated test result.
By default, "should only import" rules will be generated for modules that the diagram shows as connected. "Should not import" rules will be generated for modules that are not connected in the diagram.
__init__(should_only_rule=True)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
should_only_rule |
bool
|
if True, edges between components will be converted into 'should only import' rules. |
True
|
dependency_to_rule_converter
DependencyToRuleConverter
convert(dependencies)
Converts a parsed dependency object to a list of RuleAppliers. All explicit dependencies in the given object are converted to should (only) rules. All missing, but possible dependencies between the given modules are converted to 'should not' rules. Args: dependencies: parsed modules and dependencies between modules
Returns:
Type | Description |
---|---|
list[RuleApplier]
|
list of RuleAppliers that can be applied to an evaluable |
diagram_parser
PumlParser
Bases: DiagramParser
Parses .puml files to a dependencies object that can be used to generate architecture rules.
parse(file_path)
Syntactical requirements for .puml files:
* start of dependency definition needs to be tagged with @startuml
* end of dependency definition needs to be tagged with @enduml
* all text outside these tags is ignored
* component names must be enclosed in square brackets
* exception: if a component as been given an alias via [module name] as alias
, then the alias should not be
wrapped in square brackets
* dependencies must be with either -->, ->, <--, <-, -text->, or <-text-. The dependee is to be placed
on the side of the arrow head, the dependor on the opposite side
Args:
file_path: .puml file to parse
Returns:
Type | Description |
---|---|
ParsedDependencies
|
dependencies object that can be used to generate architecture rules. |