Closed MTomBosch closed 1 year ago
Can you please add a short sample BR Helmut
The bug descrpition is not correct as I see now. I will fix it immediately. The problem is that if addComponentTag is called but the diagram has no components then an error is created. See below example:
@startuml C4_Elements
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
' Next row does not create any problems
AddContainerTag("Job", $legendText="my custom legend text")
' Below line results in an error since no Component elements are available
'AddComponentTag("Job", $legendText="Azure Pipelines Job")
Person(personAlias, "Label", "Optional Description")
Container(containerAlias, "Label", "Technology", "Optional Description")
System(systemAlias, "Label", "Optional Description")
Rel(personAlias, containerAlias, "Label", "Optional Technology")
@enduml
It would be really nice if such calls are then simply ignored.
Hi @MTomBosch,
you could use function_exists
:
!if %function_exists("AddComponentTag")
AddComponentTag("Job", $legendText="Azure Pipelines Job")
!endif
Full sample:
@startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
' Next row does not create any problems
AddContainerTag("Job", $legendText="my custom legend text")
' Now it works with C4_Container.puml too
!if %function_exists("AddComponentTag")
AddComponentTag("Job", $legendText="Azure Pipelines Job")
!endif
Person(personAlias, "Label", "Optional Description")
Container(containerAlias, "Label", "Technology", "Optional Description", $tags="Job")
System(systemAlias, "Label", "Optional Description")
Rel(personAlias, containerAlias, "Label", "Optional Technology")
SHOW_LEGEND()
@enduml
BR Helmut
@MTomBosch, does it help? Can we close the issue? BR Helmut
Yes, sure. I somehow missed your answer. That works perfectly. Thank you
I am using a commonly used and big "styles.puml" that I would like to use in my many puml files. In this styles.puml I am also using addComponentTag to customize styling for certain tag based elements that are appearing in some but not all of my diagram puml files.
Now I came across the problem for a few of my diagram puml files that these puml files seem to be invalid since the tag that the addComponentTag() refers to is not assigned to any of the elements of the diagram.
It would be nice if this function then simply does nothing instead of producing an error.