diff --git a/C4.puml b/C4.puml index 47cf597..500cce3 100644 --- a/C4.puml +++ b/C4.puml @@ -62,12 +62,32 @@ skinparam rectangle<> { !global $tagDefaultLegend = "" !global $tagCustomLegend = "" +!unquoted function $toStereos($tags) + !if (%strlen($tags) == 0) + !return '' + !endif + !$stereos = '' + !$brPos = %strpos($tags, "+") + !while ($brPos >= 0) + !$tag = %substr($tags, 0, $brPos) + !$stereos = $stereos + '<<' + $tag + '>>' +%set_variable_value("$" + $tag + "LineLegend", %true()) + !$tags = %substr($tags, $brPos+1) + !$brPos = %strpos($tags, "+") + !endwhile + !if (%strlen($tags)>0) + !$stereos = $stereos + '<<' + $tags + '>>' +%set_variable_value("$" + $tags + "LineLegend", %true()) + !endif + !return $stereos +!endfunction + !unquoted function $toStereos($elementType, $tags) !if (%strlen($tags) == 0) !$stereos = '<<' + $elementType + '>>' %set_variable_value("$" + $elementType + "Legend", %true()) !return $stereos - !endif + !endif !$stereos = '' !$brPos = %strpos($tags, "+") !while ($brPos >= 0) @@ -319,6 +339,32 @@ rectangle "$getBoundary($label, $type)" $toStereos("boundary", $tags) as $alias ' Relationship ' ################################## +!function $getRel($direction, $alias1, $alias2, $label, $techn, $descr, $sprite, $tags) + !$rel = $alias1 + ' ' + $direction + ' ' + $alias2 + !if ($tags != "") + !$rel = $rel + ' ' + $toStereos($tags) + !endif + !$rel = $rel + ' : ' + !if ($sprite != "") + ' if it starts with & it's a OpenIconic, details see https://useiconic.com/open/ + !if (%substr($sprite, 0, 1) != "&") + !$rel = $rel + '<$'+$sprite+'> ' + !else + !$rel = $rel + '<'+$sprite+'> ' + !endif + !endif + !$rel = $rel + '**' + $label + '**' + !if ($techn != "") + ' last version of plantuml server supports automatic line breaks (no $breakType() required) + !$rel = $rel + '\n//[' + $techn + ']//' + !endif + !if ($descr != "") + ' last version of plantuml server supports automatic line breaks (no $breakDescr() required) + !$rel = $rel + '\n\n' + $descr + !endif + !return $rel +!endfunction + !unquoted procedure Rel_($alias1, $alias2, $label, $direction) $alias1 $direction $alias2 : **$label** !endprocedure @@ -326,143 +372,80 @@ $alias1 $direction $alias2 : **$label** $alias1 $direction $alias2 : **$label**\n//[$techn]// !endprocedure -!unquoted procedure Rel($from, $to, $label) -Rel_($from, $to, $label, "-->>") -!endprocedure -!unquoted procedure Rel($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "-->>") +!unquoted procedure Rel($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("-->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure BiRel($from, $to, $label) -Rel_($from, $to, $label, "<<-->>") -!endprocedure -!unquoted procedure BiRel($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "<<-->>") +!unquoted procedure BiRel($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("<<-->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure Rel_Back($from, $to, $label) -Rel_($from, $to, $label, "<<--") -!endprocedure -!unquoted procedure Rel_Back($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "<<--") +!unquoted procedure Rel_Back($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("<<--", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure Rel_Neighbor($from, $to, $label) -Rel_($from, $to, $label, "->>") -!endprocedure -!unquoted procedure Rel_Neighbor($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "->>") +!unquoted procedure Rel_Neighbor($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure Rel_Back_Neighbor($from, $to, $label) -Rel_($from, $to, $label, "<<-") -!endprocedure -!unquoted procedure Rel_Back_Neighbor($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "<<-") +!unquoted procedure Rel_Back_Neighbor($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("<<-", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure Rel_D($from, $to, $label) -Rel_($from, $to, $label, "-DOWN->>") -!endprocedure -!unquoted procedure Rel_D($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "-DOWN->>") +!unquoted procedure Rel_D($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("-DOWN->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure Rel_Down($from, $to, $label) -Rel_($from, $to, $label, "-DOWN->>") -!endprocedure -!unquoted procedure Rel_Down($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "-DOWN->>") +!unquoted procedure Rel_Down($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("-DOWN->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure BiRel_D($from, $to, $label) -Rel_($from, $to, $label, "<<-DOWN->>") -!endprocedure -!unquoted procedure BiRel_D($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "<<-DOWN->>") -!endprocedure -!unquoted procedure BiRel_Down($from, $to, $label) -Rel_($from, $to, $label, "<<-DOWN->>") +!unquoted procedure BiRel_D($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("<<-DOWN->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure BiRel_Down($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "<<-DOWN->>") +!unquoted procedure BiRel_Down($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("<<-DOWN->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure Rel_U($from, $to, $label) -Rel_($from, $to, $label, "-UP->>") -!endprocedure -!unquoted procedure Rel_U($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "-UP->>") -!endprocedure -!unquoted procedure Rel_Up($from, $to, $label) -Rel_($from, $to, $label, "-UP->>") +!unquoted procedure Rel_U($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("-UP->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure Rel_Up($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "-UP->>") +!unquoted procedure Rel_Up($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("-UP->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure BiRel_U($from, $to, $label) -Rel_($from, $to, $label, "<<-UP->>") +!unquoted procedure BiRel_U($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("<<-UP->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure BiRel_U($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "<<-UP->>") -!endprocedure -!unquoted procedure BiRel_Up($from, $to, $label) -Rel_($from, $to, $label, "<<-UP->>") -!endprocedure -!unquoted procedure BiRel_Up($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "<<-UP->>") +!unquoted procedure BiRel_Up($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("<<-UP->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure Rel_L($from, $to, $label) -Rel_($from, $to, $label, "-LEFT->>") -!endprocedure -!unquoted procedure Rel_L($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "-LEFT->>") +!unquoted procedure Rel_L($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("-LEFT->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure Rel_Left($from, $to, $label) -Rel_($from, $to, $label, "-LEFT->>") -!endprocedure -!unquoted procedure Rel_Left($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "-LEFT->>") +!unquoted procedure Rel_Left($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("-LEFT->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure BiRel_L($from, $to, $label) -Rel_($from, $to, $label, "<<-LEFT->>") -!endprocedure -!unquoted procedure BiRel_L($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "<<-LEFT->>") +!unquoted procedure BiRel_L($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("<<-LEFT->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure BiRel_Left($from, $to, $label) -Rel_($from, $to, $label, "<<-LEFT->>") -!endprocedure -!unquoted procedure BiRel_Left($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "<<-LEFT->>") +!unquoted procedure BiRel_Left($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("<<-LEFT->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure Rel_R($from, $to, $label) -Rel_($from, $to, $label, "-RIGHT->>") -!endprocedure -!unquoted procedure Rel_R($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "-RIGHT->>") -!endprocedure -!unquoted procedure Rel_Right($from, $to, $label) -Rel_($from, $to, $label, "-RIGHT->>") +!unquoted procedure Rel_R($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("-RIGHT->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure Rel_Right($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "-RIGHT->>") +!unquoted procedure Rel_Right($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("-RIGHT->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure BiRel_R($from, $to, $label) -Rel_($from, $to, $label, "<<-RIGHT->>") -!endprocedure -!unquoted procedure BiRel_R($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "<<-RIGHT->>") -!endprocedure -!unquoted procedure BiRel_Right($from, $to, $label) -Rel_($from, $to, $label, "<<-RIGHT->>") +!unquoted procedure BiRel_R($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("<<-RIGHT->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure -!unquoted procedure BiRel_Right($from, $to, $label, $techn) -Rel_($from, $to, $label, $techn, "<<-RIGHT->>") +!unquoted procedure BiRel_Right($from, $to, $label, $techn="", $descr="", $sprite="", $tags="") +$getRel("<<-RIGHT->>", $from, $to, $label, $techn, $descr, $sprite, $tags) !endprocedure ' Layout Helpers