From 4e88f3927eb7a50dda5c4574c2e02add1ea30e59 Mon Sep 17 00:00:00 2001 From: Daniel Simpson Date: Thu, 4 Feb 2021 12:25:51 +1100 Subject: [PATCH] Add ability to auto-number relationships for complex diagrams --- C4.puml | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/C4.puml b/C4.puml index 2c8d396..26df7c8 100644 --- a/C4.puml +++ b/C4.puml @@ -85,11 +85,33 @@ left to right direction ' Relationship ' ################################## +!$relationshipIndex = 0 +!$autoNumberRelationships = 0 + +!procedure AUTONUMBER_RELATIONSHIPS() + !$autoNumberRelationships = 1 +!endprocedure + +!procedure INCREMENT_RELATIONSHIP_INDEX() + !$relationshipIndex = $relationshipIndex + 1 +!endprocedure + !unquoted procedure Rel_($alias1, $alias2, $label, $direction="") -$alias1 $direction $alias2 : **$label** +!if ($autoNumberRelationships) + INCREMENT_RELATIONSHIP_INDEX() + $alias1 $direction $alias2 : **$relationshipIndex. $label** +!else + $alias1 $direction $alias2 : **$label** +!endif !endprocedure + !unquoted procedure Rel_($alias1, $alias2, $label, $techn, $direction="") -$alias1 $direction $alias2 : **$label**\n//[$techn]// +!if ($autoNumberRelationships) + INCREMENT_RELATIONSHIP_INDEX() + $alias1 $direction $alias2 : **$relationshipIndex. $label**\n//[$techn]// +!else + $alias1 $direction $alias2 : **$label**\n//[$techn]// +!endif !endprocedure !unquoted procedure Rel($from, $to, $label)