Skip to content

Commit

Permalink
#350 Boundaries in sequence diagrams support sprites and descriptions…
Browse files Browse the repository at this point in the history
… too
  • Loading branch information
kirchsth committed May 1, 2024
1 parent 9c669d0 commit 096629c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
32 changes: 20 additions & 12 deletions C4_Sequence.puml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
' convert it with additional command line argument -DRELATIVE_INCLUDE="relative/absolute" to use locally
' convert it with additional command line argument -DRELATIVE_INCLUDE="relative/absolute" to use locally
!if %variable_exists("RELATIVE_INCLUDE")
!include ./C4_Component.puml
!else
Expand Down Expand Up @@ -192,7 +192,6 @@ sequenceDiagram {
!return $breakWithNewline($text, $lineStart, $lineEnd, $REL_TECHN_MAX_CHAR_WIDTH)
!endfunction

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

!unquoted procedure Boundary($alias, $label, $type="", $tags="", $link="")
!unquoted procedure Boundary($alias, $label, $type="", $tags="", $link="", $descr = "")
!$boundaryTags = $addBoundaryPostfix($tags)
' nodes $type reuses $techn definition of $boundaryTags
' boundary $type reuses $techn definition of $boundaryTags
!$type=$toElementArg($type, $boundaryTags, "ElementTagTechn", "boundary")
!$sprite=$toElementArg("", $boundaryTags, "ElementTagSprite", "boundary")
!$labelSprite=""
!if ($sprite != "")
' add sprite in label line that it is more compact
!$labelSprite = $getSprite($smallVersionSprite($sprite, $BOUNDARY_IMAGE_SIZE_FACTOR)) + ' '
!endif
!if ($link != "")
!$usedNewLine = ']]\n== [[' + $link + ' '
!$labelType = '== [[' + $link + ' ' + $breakText($label, $usedNewLine) + ']]'
!$labelType = '== [[' + $link + ' ' + $labelSprite + $breakText($label, $usedNewLine) + ']]'
!else
!$usedNewLine = '\n== '
!$labelType = $breakText($label, $usedNewLine)
!$labelType = $labelSprite + $breakText($label, $usedNewLine)
!endif
!if (type != "")
!$labelType = $labelType + '\n<size:' + $TECHN_FONT_SIZE + '>[' + $type + ']</size>'
!endif
!if ($display_element_description == %true() && $descr != "")
!$labelType = $labelType + '\n\n' + $breakDescr($descr, $BOUNDARY_DESCR_MAX_CHAR_WIDTH)
!endif
box "$labelType" $toStereos("boundary", $boundaryTags)
!endprocedure

!procedure Boundary_End()
end box
!endprocedure

!unquoted procedure Enterprise_Boundary($alias, $label, $tags="", $link="")
!unquoted procedure Enterprise_Boundary($alias, $label, $tags="", $link="", $descr = "")
!if ($tags != "")
!$allTags = $tags + '+enterprise'
!else
!$allTags = 'enterprise'
!endif
' $type defined via $tag style
Boundary($alias, $label, "", $allTags, $link)
Boundary($alias, $label, "", $allTags, $link, $descr)
!endprocedure

!unquoted procedure System_Boundary($alias, $label, $tags="", $link="")
!unquoted procedure System_Boundary($alias, $label, $tags="", $link="", $descr = "")
!if ($tags != "")
!$allTags = $tags + '+system'
!else
!$allTags = 'system'
!endif
' $type defined via $tag style
Boundary($alias, $label, "", $allTags, $link)
Boundary($alias, $label, "", $allTags, $link, $descr)
!endprocedure

!unquoted procedure Container_Boundary($alias, $label, $tags="", $link="")
!unquoted procedure Container_Boundary($alias, $label, $tags="", $link="", $descr = "")
!if ($tags != "")
!$allTags = $tags + '+container'
!else
!$allTags = 'container'
!endif
' $type defined via $tag style
Boundary($alias, $label, "", $allTags, $link)
Boundary($alias, $label, "", $allTags, $link, $descr)
!endprocedure

' Relationship (redefinition)
Expand Down
8 changes: 7 additions & 1 deletion percy/TestSequenceSkinparams.puml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,16 @@ sequenceDiagram {
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Sequence.puml
!endif

SHOW_ELEMENT_DESCRIPTIONS()
SHOW_INDEX(true)

AddPersonTag("chatBot", $sprite="robot")
AddBoundaryTag("chatBotSystem", $type="ChatGPT", $bgColor="lightgreen", $fontColor=$PERSON_BG_COLOR, $borderColor=$PERSON_BG_COLOR, $shadowing="true", $sprite="robot2")

Person(Alice, "Alice")
Person(Bob, "Bob")
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")
Component(Bob, "Bob", $descr="This chatbot should act like a person", $tags="chatBot")
Boundary_End()

activate Bob

Expand Down

0 comments on commit 096629c

Please sign in to comment.