C4PlantUML exporter: Stereotypes shown
dgutson opened this issue · comments
Given
workspace "Test Product Architecture" "Model of the Test Platform." {
!identifiers hierarchical
model {
user1 = person "User1" "" "users"
user2 = person "User2"
frontend_user = person "FE user"
webhooks_user = person "Webhooks User" "" "robot_user"
EAS = softwaresystem "EAS" "Service1" {
SP = container "Processor" "Process1" "Node.js"
engine = container "Engine" "Processes2" "Go"
SP -> engine "Sends data"
engine -> SP "Send results"
}
backend = softwaresystem "Backend" "Backend1" "multi" {
database = container "DB" "" "MongoDB" "DB"
app = container "App" "Backend Server" "Node.js" {
s1 = component "Service1"
s2 = component "Service2"
s1 -> s2
}
app -> database "Uses"
}
backend.app -> EAS.SP "Send data"
backend.app -> EAS.engine "Sends data 2"
EAS.SP -> backend.app "Send results"
}
views {
properties {
plantuml.includes https://raw.githubusercontent.com/plantuml/plantuml-stdlib/master/tupadr3/font-awesome-5/users.puml
c4plantuml.tags true
c4plantuml.legend false
plantuml.sequenceDiagram true
}
systemlandscape TheSystemLandscape {
include *
autoLayout
}
component backend.app {
include *
autoLayout
}
theme default
styles {
element "DB" {
shape Cylinder
}
element "dataset" {
background #006400
}
element "robot_user" {
properties {
c4plantuml.sprite robot
}
}
element "users" {
properties {
c4plantuml.sprite users
}
}
element "multi" {
properties {
c4plantuml.shadow true
}
}
}
}
}
Commenting out the include does not change the behavior.
I couldn't isolate exactly what causes the stereotypes to show up.
I had to call HIDE_STEREOTYPES()
in an external puml include in order to workaround this.
Removing the whole styles {}
block also preserves the behavior.
I think I spotted it:
properties {
#plantuml.includes https://raw.githubusercontent.com/plantuml/plantuml-stdlib/master/tupadr3/font-awesome-5/users.puml
#c4plantuml.tags true
#c4plantuml.legend false
plantuml.sequenceDiagram true
}
Commenting and uncommenting c4plantuml.legend false
makes the difference between showing or not the stereotype.
It's the call to SHOW_LEGEND()
in the PlantUML that's causing the stereotypes to appear or not. These two examples both render differently:
@startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4.puml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
System(SoftwareSystem, "Software System")
SHOW_LEGEND()
@enduml
@startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4.puml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
System(SoftwareSystem, "Software System")
@enduml
You'll need to ask the C4-PlantUML team why this happens ... I suspect it's because you generally want the legend or the stereotypes, but not both, and not neither.
Why not adding HIDE_STEREOTYPES()
when c4plantuml.legend
is false
then?
Anyways I can ask to confirm.
I found this plantuml-stdlib/C4-PlantUML#37 which could be related.
@simonbrowndotje they confirmed, I think structurizr should just add the HIDE_STEREOTYPES()
call as I suggested above, since your hypothesis was correct.
Didn't test it yet but fix should look like:
--- a/src/main/java/com/structurizr/export/plantuml/C4PlantUMLExporter.java
+++ b/src/main/java/com/structurizr/export/plantuml/C4PlantUMLExporter.java
@@ -165,10 +165,13 @@ public class C4PlantUMLExporter extends AbstractPlantUMLExporter {
@Override
protected void writeFooter(View view, IndentingWriter writer) {
+ writer.writeLine();
if (includeLegend(view)) {
- writer.writeLine();
writer.writeLine("SHOW_LEGEND()");
}
+ else {
+ writer.writeLine("HIDE_STEREOTYPE()");
+ }
super.writeFooter(view, writer);
}