Skip to content

Commit 096629c

Browse files
committed
plantuml-stdlib#350 Boundaries in sequence diagrams support sprites and descriptions too
1 parent 9c669d0 commit 096629c

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

C4_Sequence.puml

+20-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
' convert it with additional command line argument -DRELATIVE_INCLUDE="relative/absolute" to use locally
1+
' convert it with additional command line argument -DRELATIVE_INCLUDE="relative/absolute" to use locally
22
!if %variable_exists("RELATIVE_INCLUDE")
33
!include ./C4_Component.puml
44
!else
@@ -192,7 +192,6 @@ sequenceDiagram {
192192
!return $breakWithNewline($text, $lineStart, $lineEnd, $REL_TECHN_MAX_CHAR_WIDTH)
193193
!endfunction
194194

195-
' description is not displayed (size too big, line breaks not supported)
196195
' properties are not displayed in sequence diagram (size would be too big)
197196
' $breakLabel() not required by participant
198197
!procedure $getParticipant($elementType, $alias, $label, $techn, $descr, $sprite, $tags, $link)
@@ -324,55 +323,64 @@ $calcDescr
324323
' alias ignored
325324
' $breakLabel() not required by participant
326325

327-
!unquoted procedure Boundary($alias, $label, $type="", $tags="", $link="")
326+
!unquoted procedure Boundary($alias, $label, $type="", $tags="", $link="", $descr = "")
328327
!$boundaryTags = $addBoundaryPostfix($tags)
329-
' nodes $type reuses $techn definition of $boundaryTags
328+
' boundary $type reuses $techn definition of $boundaryTags
330329
!$type=$toElementArg($type, $boundaryTags, "ElementTagTechn", "boundary")
330+
!$sprite=$toElementArg("", $boundaryTags, "ElementTagSprite", "boundary")
331+
!$labelSprite=""
332+
!if ($sprite != "")
333+
' add sprite in label line that it is more compact
334+
!$labelSprite = $getSprite($smallVersionSprite($sprite, $BOUNDARY_IMAGE_SIZE_FACTOR)) + ' '
335+
!endif
331336
!if ($link != "")
332337
!$usedNewLine = ']]\n== [[' + $link + ' '
333-
!$labelType = '== [[' + $link + ' ' + $breakText($label, $usedNewLine) + ']]'
338+
!$labelType = '== [[' + $link + ' ' + $labelSprite + $breakText($label, $usedNewLine) + ']]'
334339
!else
335340
!$usedNewLine = '\n== '
336-
!$labelType = $breakText($label, $usedNewLine)
341+
!$labelType = $labelSprite + $breakText($label, $usedNewLine)
337342
!endif
338343
!if (type != "")
339344
!$labelType = $labelType + '\n<size:' + $TECHN_FONT_SIZE + '>[' + $type + ']</size>'
340345
!endif
346+
!if ($display_element_description == %true() && $descr != "")
347+
!$labelType = $labelType + '\n\n' + $breakDescr($descr, $BOUNDARY_DESCR_MAX_CHAR_WIDTH)
348+
!endif
341349
box "$labelType" $toStereos("boundary", $boundaryTags)
342350
!endprocedure
343351

344352
!procedure Boundary_End()
345353
end box
346354
!endprocedure
347355

348-
!unquoted procedure Enterprise_Boundary($alias, $label, $tags="", $link="")
356+
!unquoted procedure Enterprise_Boundary($alias, $label, $tags="", $link="", $descr = "")
349357
!if ($tags != "")
350358
!$allTags = $tags + '+enterprise'
351359
!else
352360
!$allTags = 'enterprise'
353361
!endif
354362
' $type defined via $tag style
355-
Boundary($alias, $label, "", $allTags, $link)
363+
Boundary($alias, $label, "", $allTags, $link, $descr)
356364
!endprocedure
357365

358-
!unquoted procedure System_Boundary($alias, $label, $tags="", $link="")
366+
!unquoted procedure System_Boundary($alias, $label, $tags="", $link="", $descr = "")
359367
!if ($tags != "")
360368
!$allTags = $tags + '+system'
361369
!else
362370
!$allTags = 'system'
363371
!endif
364372
' $type defined via $tag style
365-
Boundary($alias, $label, "", $allTags, $link)
373+
Boundary($alias, $label, "", $allTags, $link, $descr)
366374
!endprocedure
367375

368-
!unquoted procedure Container_Boundary($alias, $label, $tags="", $link="")
376+
!unquoted procedure Container_Boundary($alias, $label, $tags="", $link="", $descr = "")
369377
!if ($tags != "")
370378
!$allTags = $tags + '+container'
371379
!else
372380
!$allTags = 'container'
373381
!endif
374382
' $type defined via $tag style
375-
Boundary($alias, $label, "", $allTags, $link)
383+
Boundary($alias, $label, "", $allTags, $link, $descr)
376384
!endprocedure
377385

378386
' Relationship (redefinition)

percy/TestSequenceSkinparams.puml

+7-1
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,16 @@ sequenceDiagram {
7171
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Sequence.puml
7272
!endif
7373

74+
SHOW_ELEMENT_DESCRIPTIONS()
7475
SHOW_INDEX(true)
7576

77+
AddPersonTag("chatBot", $sprite="robot")
78+
AddBoundaryTag("chatBotSystem", $type="ChatGPT", $bgColor="lightgreen", $fontColor=$PERSON_BG_COLOR, $borderColor=$PERSON_BG_COLOR, $shadowing="true", $sprite="robot2")
79+
7680
Person(Alice, "Alice")
77-
Person(Bob, "Bob")
81+
System_Boundary(system, "System", $tags="chatBotSystem", $descr="ChatGPT with model gpt-3.5-turbo. It has been updated to feature higher accuracy at responding in requested formats")
82+
Component(Bob, "Bob", $descr="This chatbot should act like a person", $tags="chatBot")
83+
Boundary_End()
7884

7985
activate Bob
8086

0 commit comments

Comments
 (0)