6

I have multiple single sequence diagrams. most of them have the same initialization and termination sequence.

It is possible to copy this from one file to the other but it would be much better if this part could be declared at a single point. So in case of a change it would not be necessary to change all the diagrams.

Is there a way to do this ?

Peter
  • 1,629
  • 2
  • 25
  • 45

4 Answers4

3

I tried to comment to JRI's answer but I don't have a high enough reputation.

I found that !include works until you need to include the same file multiple times. I got a solution on a plantuml forum and I can't remember the forum but I do remember the solution. On the second and each additional time you include a file you want to use !include_many.

jj2f1
  • 300
  • 1
  • 7
2

@user349062 comment is the correct answer. This was not easy to find, and its not in the documentation: Reference Guide

Using !include_many instead of !include in subsequent pages works, which doesn't make much sense, but there you go.

HAT
  • 331
  • 3
  • 8
1

Yes, you should use a reference fragment to reference the separate initialization / termination sequences:

@startuml
participant Alice
participant Bob
ref over Alice, Bob : initialization
Alice -> Bob : hello
ref over Alice, Bob : termination
@enduml
Staffan Persson
  • 151
  • 1
  • 5
1

If you want to show the detail of the re-used parts, rather than abstract them away as a reference block, PlantUML allows you to include files using the !include or !includeurl directives.

The syntax also allows you to import particular blocks of code from an imported file. See http://plantuml.com/preprocessing for details.

JRI
  • 1,766
  • 13
  • 25