Skip to content

Support PlantUML grouping keywords in component diagrams - #527

Merged
mak638 merged 1 commit into
plantuml-all-arrow-typesfrom
213-plantuml-components-grouping-support
Nov 27, 2026
Merged

mak638 merged 1 commit into
plantuml-all-arrow-typesfrom
213-plantuml-components-grouping-support

Conversation

@alexanderlinne

Copy link
Copy Markdown
Collaborator

Fixes #213

Why

Larger component diagrams group their components with package, node, folder, frame, cloud or database. The import ignored these groups, so every component needed its own stereotype, and every dependency had to be drawn between single components, even where a diagram meant a dependency between whole groups.

What changes

Groups. Components can be grouped with any of the six keywords. Like components, groups may have a color, e.g. package X #palegreen {.

@startuml
package "Ui" as ui {
  [Controller] <<Controller.*>>
  [View] <<View.*>>
}
package "Domain" as domain {
  [Model] <<Model.*>>
}

ui --> domain
@enduml

Stereotypes. A group contains no types of its own, so every component still needs its own stereotype. A stereotype on a group line is accepted but only drawn: inheriting it would make all components in the group claim the same namespaces, which ClassDiagramAssociation rejects ("Stereotype '…' should be unique").

Dependencies. A dependency from or to a group applies to all components nested in it.

  • Groups are referenced by their alias, or by their name if they have no alias.
  • A name in brackets always refers to a component, so [Shared] --> [B] refers to the component Shared even if a group has the same name, while Shared --> [B] refers to the group.
  • Dependencies are not inferred transitively (pinned by a test and documented in Support all PlantUML link types in diagram import #526).

Blocks. Braces of other blocks, e.g. skinparam component { … }, are ignored. A group that is never closed is reported as an error.

The user guide describes groups in section 4.3.

Tests. PlantUmlParserTest covers that components keep only their own stereotypes for every keyword, the error for a component in a group without its own stereotype, colored groups, dependencies between nested groups, bracketed endpoints next to a group of the same name (as origin and as target, with arrows in both directions), unclosed groups and braces of non-group blocks. ClassDiagramAssociationTest checks a grouped diagram end to end: a group stereotype assigns no types, and a group-to-group dependency allows the nested target's namespace.

After this PR, PlantUmlPatterns.cs, PlantUmlParser.cs and PlantUmlGroup.cs have 100% line and branch coverage.

Possible follow-up

A stereotype on a group could make the group a component of its own for dependency checks:

  • X --> Domain would allow X to depend on anything matching the group's stereotype.
  • Domain --> Y would apply to the group's own types as well as to the nested components.
  • A type matching both would belong to the most specific match: a nested component first, then the innermost group.
  • Types that match only the group's stereotype would become part of the diagram, so dependencies on them would be checked instead of ignored.

#213 doesn't need this, so it's left for a separate PR.

Breaking changes

  • A diagram with a group that is never closed is now rejected. Before, the group line was ignored.
  • A dependency endpoint without brackets that matches a group's alias (or name) now refers to the group. To refer to a component with the same name, use brackets.

Components can be nested in groups (package, node, folder, frame, cloud,
database), and dependencies from/to a group are expanded to all nested
components. Groups do not contain any types of their own: every component
still needs its own stereotype, and stereotypes on a group are accepted but
only drawn. Like components, groups may have a color, e.g.
`package X #palegreen {`.

Closes #213

Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
@alexanderlinne
alexanderlinne changed the base branch from main to plantuml-all-arrow-types November 27, 2026 09:49
@alexanderlinne
alexanderlinne marked this pull request as ready for review November 27, 2026 09:50
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.80%. Comparing base (c847d7c) to head (8cb6620).

Additional details and impacted files
@@                     Coverage Diff                      @@
##           plantuml-all-arrow-types     #527      +/-   ##
============================================================
+ Coverage                     86.67%   86.80%   +0.13%     
============================================================
  Files                           261      262       +1     
  Lines                         12603    12721     +118     
  Branches                       1228     1245      +17     
============================================================
+ Hits                          10924    11043     +119     
  Misses                         1337     1337              
+ Partials                        342      341       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

mak638
mak638 previously approved these changes Nov 27, 2026
@alexanderlinne
alexanderlinne dismissed mak638’s stale review November 27, 2026 22:47

The merge-base changed after approval.

@mak638
mak638 merged commit 2e44945 into main Nov 27, 2026
11 checks passed
@mak638
mak638 deleted the 213-plantuml-components-grouping-support branch November 27, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PlantUml components grouping support

3 participants