C4PlantUMLExporter mistakes container and component description for technologies when only description is present
pcolby opened this issue · comments
Description
The official Structurizr DSL reference syntax for containers and components is:
container <name> [description] [technology] [tags]
component <name> [description] [technology] [tags]
Though to be more precise, that is slightly ambiguous, and most Structurizr tooling interpret it as:
container <name> [description [technology [tags]]]
component <name> [description [technology [tags]]]
Which is to say, tags
is the most-optional, followed-by technology
, then description
. This can be seen in ContainerParser::parse() and ComponentParser::parse().
However, when C4PlantUMLExporter::writeElement() generates C4-PlantUML Container(...)
and Component(...)
procedure calls, if technology
is not set, then description
ends up in the technology
argument's positional, and this description
gets rendered as a technology
.
Steps to reproduce
- Consider this example DSL:
workspace {
model {
enterprise "Demo" {
demoSystem = softwaresystem "demoSystem" {
demoContainer = container "demoContainer" "desc" "tech" "tags" {
component "component1" "component1 description" "component1 technology" "component1 tag1,tsg2"
component "component2" "component2 description" "component2 technology"
component "component3" "component3 description"
component "component4"
}
}
}
}
views {
component demoContainer {
include *
}
}
}
-
Render that via Structurizr, and C4-PlantUML, eg via https://structurizr.com/dsl
-
Observe that only
component3
, and only in the C4-PlantUML rendering, thecomponent3 description
text appears where the technology text should. See screenshots in the next section.
Screenshot
Here's a sample show how it is correct for the Structurizr output, for all four components:
And here, you can see how for the C4-PlantUML output, component3
's description appears in the technology position:
Code sample
See "Steps to reproduce" above.
Configuration
No response
Severity
Major
Priority
Low
Resolution
I'm willing to fix this myself and raise a PR
More information
Looking at the generated C4-PlantUML (for the above sample DSL), it includes:
Container_Boundary("demoSystem.demoContainer_boundary", "demoContainer", $tags="") {
Component(demoSystem.demoContainer.component1, "component1", "component1 technology", "component1 description", $tags="")
Component(demoSystem.demoContainer.component2, "component2", "component2 technology", "component2 description", $tags="")
Component(demoSystem.demoContainer.component3, "component3", "component3 description", $tags="")
Component(demoSystem.demoContainer.component4, "component4", "", $tags="")
}
You can see that for component3
, then description has shifted into the technology position.
For convenience, here are links to the relevant current C4-PlantUML procedure definitions:
And here's the code in C4PlantUMLExporter.java
that writes (sometimes incorrectly) those procedure calls (ie this is where I'd say the fixes should go):
- C4PlantUMLExporter::writeElement() - Container[Db|Queue]
- C4PlantUMLExporter::writeElement() - Component[Db|Queue]
Note, the components fix will likely conflict with my existing open PR #60, so I would strongly recommend merging that PR (assuming you're happy with it) before fixing this. Or branch off my PR.
I'd be happy to have a go at fixing this bug too. Just not sure when I'll have time to get to it.
Cheers!
Thanks ... given that the code in the exporter explicitly does something different for null/empty technologies, I'm guessing something has recently changed with PlantUML and/or C4-PlantUML to make this invalid ... especially since nobody has raised this before. I will merge your PR, then resolve this issue.