user1605665
user1605665

Reputation: 4151

How do I auto activate and destroy in a plant uml sequence diagram

In PlantUML adding activation lines in a sequence diagram can be very messy. Is there any way to make it auto activate and deactivate without all the extra text?

e.g.

Generate Sequence diagram without activation lines

@startuml

First -> Second
Second -> Third
Third -> Second
Second ->  First

@enduml

enter image description here

But to add the activation lines its gets quite messy

@startuml

First -> Second : message
activate First
activate Second
Second -> Third: message
activate Third
Third -> Second: response
deactivate Third
Second ->  First: response
deactivate First
deactivate Second

@enduml

enter image description here

I'm wondering if there is its possible to have it auto detect the likely create destroy points automatically

Upvotes: 13

Views: 13503

Answers (1)

Peter Uhnak
Peter Uhnak

Reputation: 10217

Yes (2017) with autoactivate on; the syntax is still in incubation, however it has been part of the distribution for some time.

Note that in all cases you still need to manually activate the First one, because there's no incoming message.

Compact syntax

If you want to maintain control of the (de)activation, you can express activation/deactivation with ++ and -- symbols on the same line to activate the target.

activate First
First -> Second ++ : message12
Second -> Third ++ : message23
Third -> Second -- : response32
Second ->  First -- : response21
deactivate First

enter image description here

autoactivate on

With your original description you will quickly find out that you need to describe your lines properly as a return, otherwise you'll be activating ad nauseam.

autoactivate on
activate First
First -> Second
Second -> Third
Third --> Second
Second --> First
deactivate First

enter image description here

Upvotes: 22

Related Questions