From 8cace5ed5c434553255960d4215835ba119b692f Mon Sep 17 00:00:00 2001 From: kirchsth Date: Fri, 10 May 2024 16:27:44 +0200 Subject: [PATCH] #355 Single column property --- C4.puml | 14 ++++++++++---- README.md | 4 ++-- percy/TestProperty.puml | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 percy/TestProperty.puml diff --git a/C4.puml b/C4.puml index f0a2d852..2792da9a 100644 --- a/C4.puml +++ b/C4.puml @@ -1151,9 +1151,12 @@ $elementSkin !global $propTableCaption = "" !global $propColCaption = "=" -!unquoted function SetPropertyHeader($col1Name, $col2Name, $col3Name = "", $col4Name = "") +!unquoted function SetPropertyHeader($col1Name, $col2Name = "", $col3Name = "", $col4Name = "") !$propColCaption = "" - !$propTableCaption = "|= " + $col1Name + " |= " + $col2Name + " |" + !$propTableCaption = "|= " + $col1Name + " |" + !if ($col2Name != "") + !$propTableCaption = $propTableCaption + "= " + $col2Name + " |" + !endif !if ($col3Name != "") !$propTableCaption = $propTableCaption + "= " + $col3Name + " |" !endif @@ -1169,7 +1172,7 @@ $elementSkin !return "" !endfunction -!unquoted function AddProperty($col1, $col2, $col3 = "", $col4 = "") +!unquoted function AddProperty($col1, $col2 = "", $col3 = "", $col4 = "") !if ($propTable == "") !if ($propTableCaption != "") !$propTable = $propTableCaption + "\n" @@ -1177,7 +1180,10 @@ $elementSkin !else !$propTable = $propTable + "\n" !endif - !$propTable = $propTable + "| " + $col1 + " |" + $propColCaption + " " + $col2 + " |" + !$propTable = $propTable + "| " + $col1 + " |" + !if ($col2 != "") + !$propTable = $propTable + $propColCaption + " " + $col2 + " |" + !endif !if ($col3 != "") !$propTable = $propTable + " " + $col3 + " |" !endif diff --git a/README.md b/README.md index 5aa8a62a..68a001c5 100644 --- a/README.md +++ b/README.md @@ -875,11 +875,11 @@ SHOW_LEGEND() A model can be extended with (a table of) properties that concrete deployments or more detailed concepts can be documented: -- `SetPropertyHeader(col1Name, col2Name, ?col3Name, ?col4Name)` +- `SetPropertyHeader(col1Name, ?col2Name, ?col3Name, ?col4Name)` The properties table can have up to 4 columns. The default header uses the column names "Name", "Description". - `WithoutPropertyHeader()` If no header is used, then the second column is bold. -- `AddProperty(col1, col2, ?col3, ?col4)` +- `AddProperty(col1, ?col2, ?col3, ?col4)` (All columns of) a property which will be added to the next element. Following sample uses all 3 different property definitions (and the aligned deployment node). diff --git a/percy/TestProperty.puml b/percy/TestProperty.puml new file mode 100644 index 00000000..1e26913a --- /dev/null +++ b/percy/TestProperty.puml @@ -0,0 +1,36 @@ +@startuml +' convert it with additional command line argument -DRELATIVE_INCLUDE="./.." to use locally +!if %variable_exists("RELATIVE_INCLUDE") + !include %get_variable_value("RELATIVE_INCLUDE")/C4_Deployment.puml +!else + !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Deployment.puml +!endif + +' default header Property, Value +AddProperty("Name", "Flash") +AddProperty("Organization", "Zootopia") +AddProperty("Tool", "Internet Explorer 7.0") +Person(personAlias, "Label", "Optional Description (with default property header)") + +SetPropertyHeader("Property","Value", "Description") +AddProperty("Prop1", "Value1", "Details1") +AddProperty("Prop2", "Value2", "Details2") +Deployment_Node_L(nodeAlias, "Label", "Optional Type", "Optional Description (with custom property header)") { + + WithoutPropertyHeader() + AddProperty("PropC1", "ValueC1") + AddProperty("PropC2", "ValueC2") + Container(containerAlias, "Label", "Technology", "Optional Description (without property header)") +} + +SetPropertyHeader("Property") +AddProperty("Value1") +AddProperty("Value2") +System(systemAlias, "Label", "Optional Description\n(single column property)") + +' starting with v.2.5.0 relationships support properties too +WithoutPropertyHeader() +AddProperty("PropC1", "ValueC1") +AddProperty("PropC2", "ValueC2") +Rel(personAlias, containerAlias, "Label", "Optional Technology", "Optional Description") +@enduml