Friday, 10 May 2024

PlantUML: Include sub part of a file

Using the keyword !startsub, !endsub, !includesub, you can specify subparts and include them in a file.

Define part

!startsub SubPart1
	S1 -> S2 : SubPart1 msg1
	S1 -> S3 : SubPart1 msg2
	S1 -> S4 : SubPart1 msg3
!endsub

Use the part

!includesub parts.txt!SubPart1

 

parts.txt

@startuml

!startsub SubPart1
	S1 -> S2 : SubPart1 msg1
	S1 -> S3 : SubPart1 msg2
	S1 -> S4 : SubPart1 msg3
!endsub

!startsub SubPart2
	D1 -> D2 : SubPart2 msg1
	D1 -> D3 : SubPart3 msg2
	D1 -> D4 : SubPart3 msg3
!endsub

@enduml

subPartsDemo.txt

@startuml

S1 --> S5 : local message
!includesub parts.txt!SubPart1
S1 --> S6 : local message

@enduml

Above snippet generate below diagram.


Previous                                                    Next                                                    Home

No comments:

Post a Comment