From d799a4c5d55d07037e8c2c8203fbc0b7627d30a8 Mon Sep 17 00:00:00 2001 From: KIRCHSTH Date: Sat, 9 Jan 2021 13:06:08 +0100 Subject: [PATCH 1/2] #93: local file includes can be activated via command line argument -DRELATIVE_INCLUDE="." Update github workflow that local files are used --- .github/workflows/run-percy-tests.yml | 2 +- C4_Component.puml | 9 +- C4_Component_LocalSupport.puml | 88 +++++++++++++++++++ C4_Container.puml | 9 +- C4_Context.puml | 9 +- C4_Deployment.puml | 9 +- C4_Dynamic.puml | 9 +- README.md | 9 +- ...Component Diagram Sample - bigbankplc.puml | 10 ++- ...Container Diagram Sample - bigbankplc.puml | 9 +- ...ontainer Diagram Sample - message bus.puml | 12 +-- ...ntainer Diagram Sample - techtribesjs.puml | 12 +-- ...Diagram Sample - bigbankplc-landscape.puml | 8 +- ...4_Context Diagram Sample - bigbankplc.puml | 8 +- ...4_Context Diagram Sample - enterprise.puml | 10 ++- 15 files changed, 166 insertions(+), 47 deletions(-) create mode 100644 C4_Component_LocalSupport.puml diff --git a/.github/workflows/run-percy-tests.yml b/.github/workflows/run-percy-tests.yml index 8433ed4..7aed58d 100644 --- a/.github/workflows/run-percy-tests.yml +++ b/.github/workflows/run-percy-tests.yml @@ -19,7 +19,7 @@ jobs: - name: Process diagrams uses: Timmy/plantuml-action@v1 with: - args: '-v percy -o _parsed' + args: '-v percy -o _parsed -DRELATIVE_INCLUDE="."' - name: Upload run: npx percy upload percy/_parsed env: diff --git a/C4_Component.puml b/C4_Component.puml index ef92391..942410d 100644 --- a/C4_Component.puml +++ b/C4_Component.puml @@ -1,6 +1,9 @@ -!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml -' uncomment the following line and comment the first to use locally -' !include C4_Container.puml +' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally +!include https://raw.githubu!if %variable_exists("RELATIVE_INCLUDE") + !include %get_variable_value("RELATIVE_INCLUDE")/C4_Container.puml +!else + !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml +!endif ' Scope: A single container. ' Primary elements: Components within the container in scope. diff --git a/C4_Component_LocalSupport.puml b/C4_Component_LocalSupport.puml new file mode 100644 index 0000000..741dfd7 --- /dev/null +++ b/C4_Component_LocalSupport.puml @@ -0,0 +1,88 @@ +!if %variable_exists("RELATIVE_INCLUDE") + !include %get_variable_value("RELATIVE_INCLUDE")/C4_Container.puml +!else + !include https://raw.githubusercontent.com/kirchsth/C4-PlantUML/extended/C4_Container.puml +!endif + +' Scope: A single container. +' Primary elements: Components within the container in scope. +' Supporting elements: Containers (within the software system in scope) plus people and software systems directly connected to the components. +' Intended audience: Software architects and developers. + +' Colors +' ################################## + +!global $COMPONENT_FONT_COLOR = "#000000" + +!global $COMPONENT_BG_COLOR = "#85BBF0" +!global $COMPONENT_BORDER_COLOR = "#78A8D8" +!global $EXTERNAL_COMPONENT_BG_COLOR = "#CCCCCC" +!global $EXTERNAL_COMPONENT_BORDER_COLOR = "#BFBFBF" + +' Styling +' ################################## + +UpdateSkinparamsAndLegendEntry("component", $COMPONENT_BG_COLOR, $COMPONENT_FONT_COLOR, $COMPONENT_BORDER_COLOR) +UpdateSkinparamsAndLegendEntry("external_component", $EXTERNAL_COMPONENT_BG_COLOR, $COMPONENT_FONT_COLOR, $EXTERNAL_COMPONENT_BORDER_COLOR) + +' Layout +' ################################## + +SetDefaultLegendEntries("person\nsystem\ncontainer\ncomponent\nexternal_person\nexternal_system\nexternal_container\nexternal_component") + +!procedure LAYOUT_WITH_LEGEND() +hide stereotype +legend right +|**Legend** | +|<$PERSON_BG_COLOR> person | +|<$SYSTEM_BG_COLOR> system | +|<$CONTAINER_BG_COLOR> container | +|<$COMPONENT_BG_COLOR> component | +|<$EXTERNAL_PERSON_BG_COLOR> external person | +|<$EXTERNAL_SYSTEM_BG_COLOR> external system | +|<$EXTERNAL_CONTAINER_BG_COLOR> external container | +|<$EXTERNAL_COMPONENT_BG_COLOR> external component | +endlegend +!endprocedure + +' Elements +' ################################## + +!function $getComponent($label, $techn, $descr, $sprite) +!if ($descr == "") && ($sprite == "") +!return '=='+$label+'\n//['+$techn+']//' +!endif +!if ($descr == "") && ($sprite != "") +!return '<$'+$sprite+'>\n=='+$label+'\n//['+$techn+']//' +!endif +!if ($descr != "") && ($sprite == "") +!return '=='+$label+'\n//['+$techn+']//\n\n '+$descr +!endif +!if ($descr != "") && ($sprite != "") +!return '<$'+$sprite+'>\n=='+$label+'\n//['+$techn+']//\n\n '+$descr +!endif +!endfunction + +!unquoted procedure Component($alias, $label, $techn, $descr="", $sprite="", $tags="") +rectangle "$getComponent($label, $techn, $descr, $sprite)" $toStereos("component",$tags) as $alias +!endprocedure + +!unquoted procedure ComponentDb($alias, $label, $techn, $descr="", $sprite="", $tags="") +database "$getComponent($label, $techn, $descr, $sprite)" $toStereos("component",$tags) as $alias +!endprocedure + +!unquoted procedure ComponentQueue($alias, $label, $techn, $descr="", $sprite="", $tags="") +queue "$getComponent($label, $techn, $descr, $sprite)" $toStereos("component",$tags) as $alias +!endprocedure + +!unquoted procedure Component_Ext($alias, $label, $techn, $descr="", $sprite="", $tags="") +rectangle "$getComponent($label, $techn, $descr, $sprite)" $toStereos("external_component",$tags) as $alias +!endprocedure + +!unquoted procedure ComponentDb_Ext($alias, $label, $techn, $descr="", $sprite="", $tags="") +database "$getComponent($label, $techn, $descr, $sprite)" $toStereos("external_component",$tags) as $alias +!endprocedure + +!unquoted procedure ComponentQueue_Ext($alias, $label, $techn, $descr="", $sprite="", $tags="") +queue "$getComponent($label, $techn, $descr, $sprite)" $toStereos("external_component",$tags) as $alias +!endprocedure \ No newline at end of file diff --git a/C4_Container.puml b/C4_Container.puml index 996304f..ad7d31f 100644 --- a/C4_Container.puml +++ b/C4_Container.puml @@ -1,6 +1,9 @@ -!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml -' uncomment the following line and comment the first to use locally -' !include C4_Context.puml +' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally +!include https://raw.githubu!if %variable_exists("RELATIVE_INCLUDE") + !include %get_variable_value("RELATIVE_INCLUDE")/C4_Context.puml +!else + !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml +!endif ' Scope: A single software system. ' Primary elements: Containers within the software system in scope. diff --git a/C4_Context.puml b/C4_Context.puml index d15e73a..8844ef4 100644 --- a/C4_Context.puml +++ b/C4_Context.puml @@ -1,6 +1,9 @@ -!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4.puml -' uncomment the following line and comment the first to use locally -' !include C4.puml +' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally +!include https://raw.githubu!if %variable_exists("RELATIVE_INCLUDE") + !include %get_variable_value("RELATIVE_INCLUDE")/C4.puml +!else + !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4.puml +!endif ' Scope: A single software system. ' Primary elements: The software system in scope. diff --git a/C4_Deployment.puml b/C4_Deployment.puml index 7d65d84..a9c7412 100644 --- a/C4_Deployment.puml +++ b/C4_Deployment.puml @@ -1,6 +1,9 @@ -!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml -' uncomment the following line and comment the first to use locally -' !include C4_Container.puml +' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally +!include https://raw.githubu!if %variable_exists("RELATIVE_INCLUDE") + !include %get_variable_value("RELATIVE_INCLUDE")/C4_Container.puml +!else + !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml +!endif ' Styling ' ################################## diff --git a/C4_Dynamic.puml b/C4_Dynamic.puml index b41eb63..ee0e827 100644 --- a/C4_Dynamic.puml +++ b/C4_Dynamic.puml @@ -1,6 +1,9 @@ -!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml -' uncomment the following line and comment the first to use locally -' !include C4_Component.puml +' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally +!include https://raw.githubu!if %variable_exists("RELATIVE_INCLUDE") + !include %get_variable_value("RELATIVE_INCLUDE")/C4_Component.puml +!else + !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml +!endif ' Scope: Interactions in an enterprise, software system or container. ' Primary and supporting elements: Depends on the diagram scope - diff --git a/README.md b/README.md index 8cddaa4..1301e0d 100644 --- a/README.md +++ b/README.md @@ -18,17 +18,12 @@ C4-PlantUML includes macros, stereotypes, and other goodies (like VSCode Snippet At the top of your C4 PlantUML `.puml` file, you need to include the `C4_Context.puml`, `C4_Container.puml` or `C4_Component.puml` file found in the `root` of this repo. -To be independent of any internet connectivity, you can also download the files found in the `root` and reference it locally with +To be independent of any internet connectivity, you can also download the files found in the `root` and activate the relative include with additional command line argument `-DRELATIVE_INCLUDE="."` ```c# -!include path/to/C4.puml -!include path/to/C4_Context.puml -!include path/to/C4_Container.puml -!include path/to/C4_Component.puml +java -jar plantuml.jar -DRELATIVE_INCLUDE="." ... ``` -Just remember to change the `!include` statements at the top of the files. - If you want to use the always up-to-date version in this repo, use the following: ```c# diff --git a/percy/C4_Component Diagram Sample - bigbankplc.puml b/percy/C4_Component Diagram Sample - bigbankplc.puml index bf74c32..93762ff 100644 --- a/percy/C4_Component Diagram Sample - bigbankplc.puml +++ b/percy/C4_Component Diagram Sample - bigbankplc.puml @@ -1,8 +1,10 @@ @startuml -!include ./../C4_Component.puml -!include ./../C4_Container.puml -!include ./../C4_Context.puml -!include ./../C4.puml +' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally +!if %variable_exists("RELATIVE_INCLUDE") + !include ./../C4_Component.puml +!else + !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml +!endif LAYOUT_WITH_LEGEND() diff --git a/percy/C4_Container Diagram Sample - bigbankplc.puml b/percy/C4_Container Diagram Sample - bigbankplc.puml index 799f99f..241c3a5 100644 --- a/percy/C4_Container Diagram Sample - bigbankplc.puml +++ b/percy/C4_Container Diagram Sample - bigbankplc.puml @@ -1,7 +1,10 @@ @startuml -!include ./../C4_Container.puml -!include ./../C4_Context.puml -!include ./../C4.puml +' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally +!if %variable_exists("RELATIVE_INCLUDE") + !include ./../C4_Container.puml +!else + !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml +!endif LAYOUT_TOP_DOWN() 'LAYOUT_AS_SKETCH() diff --git a/percy/C4_Container Diagram Sample - message bus.puml b/percy/C4_Container Diagram Sample - message bus.puml index d57d3d6..89824d0 100644 --- a/percy/C4_Container Diagram Sample - message bus.puml +++ b/percy/C4_Container Diagram Sample - message bus.puml @@ -1,7 +1,10 @@ -@startuml "bigbankplc" -!include ./../C4_Container.puml -!include ./../C4_Context.puml -!include ./../C4.puml +@startuml +' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally +!if %variable_exists("RELATIVE_INCLUDE") + !include ./../C4_Container.puml +!else + !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml +!endif skinparam wrapWidth 200 skinparam maxMessageSize 200 @@ -10,7 +13,6 @@ LAYOUT_TOP_DOWN() 'LAYOUT_AS_SKETCH() LAYOUT_WITH_LEGEND() - Person(customer, Customer, "A customer") System_Boundary(c1, "Customer Information") { diff --git a/percy/C4_Container Diagram Sample - techtribesjs.puml b/percy/C4_Container Diagram Sample - techtribesjs.puml index d78a459..898844e 100644 --- a/percy/C4_Container Diagram Sample - techtribesjs.puml +++ b/percy/C4_Container Diagram Sample - techtribesjs.puml @@ -1,13 +1,15 @@ -@startuml "techtribesjs" -!include ./../C4_Container.puml -!include ./../C4_Context.puml -!include ./../C4.puml +@startuml +' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally +!if %variable_exists("RELATIVE_INCLUDE") + !include ./../C4_Container.puml +!else + !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml +!endif LAYOUT_TOP_DOWN() 'LAYOUT_AS_SKETCH() LAYOUT_WITH_LEGEND() - Person_Ext(anonymous_user, "Anonymous User") Person(aggregated_user, "Aggregated User") Person(administration_user, "Administration User") diff --git a/percy/C4_Context Diagram Sample - bigbankplc-landscape.puml b/percy/C4_Context Diagram Sample - bigbankplc-landscape.puml index 73915dc..b7ca084 100644 --- a/percy/C4_Context Diagram Sample - bigbankplc-landscape.puml +++ b/percy/C4_Context Diagram Sample - bigbankplc-landscape.puml @@ -1,6 +1,10 @@ @startuml -!include ./../C4_Context.puml -!include ./../C4.puml +' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally +!if %variable_exists("RELATIVE_INCLUDE") + !include ./../C4_Context.puml +!else + !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml +!endif 'LAYOUT_TOP_DOWN() 'LAYOUT_AS_SKETCH() diff --git a/percy/C4_Context Diagram Sample - bigbankplc.puml b/percy/C4_Context Diagram Sample - bigbankplc.puml index 98f35cd..a540da0 100644 --- a/percy/C4_Context Diagram Sample - bigbankplc.puml +++ b/percy/C4_Context Diagram Sample - bigbankplc.puml @@ -1,6 +1,10 @@ @startuml -!include ./../C4_Context.puml -!include ./../C4.puml +' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally +!if %variable_exists("RELATIVE_INCLUDE") + !include ./../C4_Context.puml +!else + !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml +!endif LAYOUT_WITH_LEGEND() diff --git a/percy/C4_Context Diagram Sample - enterprise.puml b/percy/C4_Context Diagram Sample - enterprise.puml index dc8d084..b407c2f 100644 --- a/percy/C4_Context Diagram Sample - enterprise.puml +++ b/percy/C4_Context Diagram Sample - enterprise.puml @@ -1,6 +1,10 @@ -@startuml "enterprise" -!include ./../C4_Context.puml -!include ./../C4.puml +@startuml +' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally +!if %variable_exists("RELATIVE_INCLUDE") + !include ./../C4_Context.puml +!else + !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml +!endif LAYOUT_TOP_DOWN() 'LAYOUT_AS_SKETCH() From b0d1692be214fca237ed25f37954702b4fc2757a Mon Sep 17 00:00:00 2001 From: KIRCHSTH Date: Sat, 9 Jan 2021 16:11:57 +0100 Subject: [PATCH 2/2] #93: local file includes can be activated via command line argument -DRELATIVE_INCLUDE="." (2 - fix !if) --- C4_Component.puml | 2 +- C4_Container.puml | 2 +- C4_Context.puml | 2 +- C4_Deployment.puml | 2 +- C4_Dynamic.puml | 2 +- README.md | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/C4_Component.puml b/C4_Component.puml index 942410d..cc76765 100644 --- a/C4_Component.puml +++ b/C4_Component.puml @@ -1,5 +1,5 @@ ' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally -!include https://raw.githubu!if %variable_exists("RELATIVE_INCLUDE") +!if %variable_exists("RELATIVE_INCLUDE") !include %get_variable_value("RELATIVE_INCLUDE")/C4_Container.puml !else !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml diff --git a/C4_Container.puml b/C4_Container.puml index ad7d31f..6a1622d 100644 --- a/C4_Container.puml +++ b/C4_Container.puml @@ -1,5 +1,5 @@ ' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally -!include https://raw.githubu!if %variable_exists("RELATIVE_INCLUDE") +!if %variable_exists("RELATIVE_INCLUDE") !include %get_variable_value("RELATIVE_INCLUDE")/C4_Context.puml !else !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml diff --git a/C4_Context.puml b/C4_Context.puml index 8844ef4..1178fd6 100644 --- a/C4_Context.puml +++ b/C4_Context.puml @@ -1,5 +1,5 @@ ' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally -!include https://raw.githubu!if %variable_exists("RELATIVE_INCLUDE") +!if %variable_exists("RELATIVE_INCLUDE") !include %get_variable_value("RELATIVE_INCLUDE")/C4.puml !else !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4.puml diff --git a/C4_Deployment.puml b/C4_Deployment.puml index a9c7412..3e49ee1 100644 --- a/C4_Deployment.puml +++ b/C4_Deployment.puml @@ -1,5 +1,5 @@ ' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally -!include https://raw.githubu!if %variable_exists("RELATIVE_INCLUDE") +!if %variable_exists("RELATIVE_INCLUDE") !include %get_variable_value("RELATIVE_INCLUDE")/C4_Container.puml !else !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml diff --git a/C4_Dynamic.puml b/C4_Dynamic.puml index ee0e827..ff4d007 100644 --- a/C4_Dynamic.puml +++ b/C4_Dynamic.puml @@ -1,5 +1,5 @@ ' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally -!include https://raw.githubu!if %variable_exists("RELATIVE_INCLUDE") +!if %variable_exists("RELATIVE_INCLUDE") !include %get_variable_value("RELATIVE_INCLUDE")/C4_Component.puml !else !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml diff --git a/README.md b/README.md index 1301e0d..73db967 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ C4-PlantUML includes macros, stereotypes, and other goodies (like VSCode Snippet At the top of your C4 PlantUML `.puml` file, you need to include the `C4_Context.puml`, `C4_Container.puml` or `C4_Component.puml` file found in the `root` of this repo. -To be independent of any internet connectivity, you can also download the files found in the `root` and activate the relative include with additional command line argument `-DRELATIVE_INCLUDE="."` +To be independent of any internet connectivity, you can also download the files found in the `root` and activate the local conversion with additional command line argument `-DRELATIVE_INCLUDE="."` (that the local files are included) ```c# java -jar plantuml.jar -DRELATIVE_INCLUDE="." ...