PlantUml: How to do a multiline display in opt condition for sequence diagram

Viewed 1434

Im trying to do a UML diagram for a script below in PlantUML.

[plantuml, target=diagram-sequence, format=png] 
....
@startuml
-> A: test
opt ((Exterme_DANGER_Forwith_cIES_MICRO_GYRO) || (Exterme_DANGER_Forwith_cIES_PANASONIC_GYRO)  || (Exterme_DANGER_Forwith_cIES_VIRTUAL)    || (Exterme_DANGER_Forwith_cIES_Cobra)     || (Exterme_DANGER_Forwith_cIES_VTI)    || (Exterme_DANGER_Forwith_cIES_VTI_SPI)    || (Exterme_DANGER_Forwith_cIES_VIRTUAL)    || (Exterme_DANGER_Forwith_cIES_VTI)     || (Exterme_DANGER_Forwith_cIES_VTI_SPI)   || (Exterme_DANGER_Forwith_cIES_VIRTUAL))    || (Exterme_DANGER_Forwith_cIES_Cobra5)  || (Exterme_DANGER_Forwith_cIES_Cobra4))
<- A
end opt
@enduml
....

When I do this I cannot see the complete diagram. PlantUML DIAGRAM

Does anyone know of a way to show the big opt conditon in multiple lines in the diagram?

1 Answers

Adding newlines \n will break the opt across multiple lines in the diagram, but it will still be on one in the PlantUML text file, which can be hard to read.

To make things more readable, adding \ at the end of the line will allow splitting text across multiple lines.

Combining \n with \ allow splitting the single line across multiple lines in both the diagram and the file:

@startuml
-> A: test
opt ( \
    (Exterme_DANGER_Forwith_cIES_MICRO_GYRO)       \n\
    || (Exterme_DANGER_Forwith_cIES_PANASONIC_GYRO)\n\
    || (Exterme_DANGER_Forwith_cIES_VIRTUAL)       \n\
    || (Exterme_DANGER_Forwith_cIES_Cobra)         \n\
    || (Exterme_DANGER_Forwith_cIES_VTI)           \n\
    || (Exterme_DANGER_Forwith_cIES_VTI_SPI)       \n\
    || (Exterme_DANGER_Forwith_cIES_VIRTUAL)       \n\
    || (Exterme_DANGER_Forwith_cIES_VTI)           \n\
    || (Exterme_DANGER_Forwith_cIES_VTI_SPI)       \n\
    || (Exterme_DANGER_Forwith_cIES_VIRTUAL))      \n\
    || (Exterme_DANGER_Forwith_cIES_Cobra5)        \n\
    || (Exterme_DANGER_Forwith_cIES_Cobra4)        \n\
)
<- A
end opt
@enduml

Related