ASCII Art
Es posible generar Diagramas de Secuencia utilizando ASCII art.
@startuml
participant Bob
actor Alice
Bob -> Alice : hello
Alice -> Bob : Is it ok?
@enduml
Debe utilizar la bandera
-txt en la línea de comandos, o la etiqueta format en la tarea Ant:
<target name="main">
<plantuml dir="./src" format="txt" />
</target>
Los archivos generados utilizan la extensión .atxt. ("a" como arte ASCII : ¡para NO anular ningún archivo .txt existente!). Aquí está el resultado:
,-.
`-'
/|\
,---. |
|Bob| / \
`-+-' Alice
| hello |
|-------------->|
| |
| Is it ok? |
|<- - - - - - - |
,-+-. Alice
|Bob| ,-.
`---' `-'
/|\
|
/ \
Puede controlar el número máximo de caracteres entre los participantes utilizando skinparam maxAsciiMessageLength. Esto puede ser útil si necesita limitar el ancho de su ASCII Art.
@startuml
skinparam maxAsciiMessageLength 8
participant Bob
actor Alice
Bob -> Alice : hello
Alice -> Bob : Is it ok?
@enduml
Se verá como:
,-.
`-'
/|\
,---. |
|Bob| / \
`-+-' Alice
|hello |
|------>|
| |
Is it ok?
|<------|
,-+-. Alice
|Bob| ,-.
`---' `-'
/|\
|
/ \
Unicode
El formato txt por defecto usa sólo carácteres ASCII plano. También es posible usar algunos caracteres Unicode para mejorar el resultado. Para ello debes usar la opción
-utxt en la línea de comando, o el formato utxt en la Tarea ANT.
┌─┐
║"│
└┬┘
┌┼┐
┌───┐ │
│Bob│ ┌┴┐
└─┬─┘ Alice
│ hello │
│──────────────>│
│ │
│ Is it ok? │
│<─ ─ ─ ─ ─ ─ ─ │
┌─┴─┐ Alice
│Bob│ ┌─┐
└───┘ ║"│
└┬┘
┌┼┐
│
┌┴┐
Existen dos desventajas usando utxt:
- El resultado es codificado como UTF-8, y algunas esto provoca fallos (mail gateway, editores...)
- The used font must have the used extended characters (like Courier, Courier New...)
WARNING
This translation need to be updated. WARNING
Diagramas Complejos
Puedes probar ejemplos más complejos si lo deseas.
@startuml
'hide footbox
participant "Bob on\nseveral lines" as Bob
actor Alice
Bob -> Alice : hello
note right of Alice
this is a note
end note
Alice -> Bob : Is it ok\nwith a message that is\non several lines?
note right
This other note
should work
on several lines
end note
== This is a separation ==
Bob -> Last : Yes it works!
Last -> Last : working in progress
note left : this is\nanother note
Last --> Last : working in progress
Last --> Bob : done
opt dummy comment
Bob -> Last : Error\nOn\nSeveral\nLine
Last --> Bob : None
else
Last --> Bob : None
Last -> Bob : None
else other
Last -> Bob : None
note over Alice, Last
This is a long note
over Alice and Last
end note
Last -> Bob : None
Last -> Bob : None
end
@enduml
Resultado
,-.
`-'
,-------------. /|\
|Bob on | | ,----.
|several lines| / \ |Last|
`------+------' Alice `-+--'
| hello | |
|---------------------->| |
| | |
| | ,--------------!.
| | |this is a note|_\
| | `----------------'
|Is it ok | ,----------------!.
|with a message that is | |This other note |_\
|on several lines? | |should work |
|<----------------------| |on several lines |
| | `------------------'
| | |
| ======================== |
====================================== This is a separation =======================================
| ======================== |
| | |
| Yes it works! |
|-------------------------------------->|
| | |
| ,------------!. |----.
| |this is |_\| | working in progress
| |another note ||<---'
| `--------------'|
| | |- - .
| | | | working in progress
| | |< - '
| | |
| done | |
|<- - - - - - - - - - - - - - - - - - - |
| | |
______________________________________________________________________
! OPT / dummy comment | | !
!_____/ | | | !
! | | | !
! | Error | | !
! | On | | !
! | Several | | !
! | Line | | !
! |-------------------------------------->| !
! | | | !
! | None | | !
! |<- - - - - - - - - - - - - - - - - - - | !
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
! | | | !
! | None | | !
! |<- - - - - - - - - - - - - - - - - - - | !
! | | | !
! | None | | !
! |<--------------------------------------| !
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
! [other] | | | !
! | None | | !
! |<--------------------------------------| !
! | | | !
! | ,-------------------!. !
! | |This is a long note|_\ !
! | |over Alice and Last | !
! | `---------------------' !
! | None | | !
! |<--------------------------------------| !
! | | | !
! | None | | !
! |<--------------------------------------| !
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
,------+------. Alice ,-+--.
|Bob on | ,-. |Last|
|several lines| `-' `----'
`-------------' /|\
|
/ \
El mismo ejemplo usando Unicode
┌─┐
║"│
└┬┘
┌─────────────┐ ┌┼┐
│Bob on │ │ ┌────┐
│several lines│ ┌┴┐ │Last│
└──────┬──────┘ Alice └─┬──┘
│ hello │ │
│──────────────────────>│ │
│ │ │
│ │ ╔═════════════╧══╗
│ │ ║this is a note ░║
│ │ ╚═════════════╤══╝
│Is it ok │ ╔═════════════╧════╗
│with a message that is │ ║This other note ░║
│on several lines? │ ║should work ║
│<──────────────────────│ ║on several lines ║
│ │ ╚═════════════╤════╝
│ │ │
│ ╔════════╧═════════════╗ │
══════════════════════╪══════════════╣ This is a separation ╠═╪════════════════════════════════════
│ ╚════════╤═════════════╝ │
│ │ │
│ Yes it works! │
│──────────────────────────────────────>│
│ │ │
│ ╔══════════════╗│────┐
│ ║this is ░║│ │ working in progress
│ ║another note ║│<───┘
│ ╚══════════════╝│
│ │ │─ ─ ┐
│ │ │ | working in progress
│ │ │< ─ ┘
│ │ │
│ done │ │
│<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │
│ │ │
╔══════╤═════════╪═══════════════════════╪═══════════════╪════════════╗
║ OPT │ dummy comment │ │ ║
╟──────┘ │ │ │ ║
║ │ │ │ ║
║ │ Error │ │ ║
║ │ On │ │ ║
║ │ Several │ │ ║
║ │ Line │ │ ║
║ │──────────────────────────────────────>│ ║
║ │ │ │ ║
║ │ None │ │ ║
║ │<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │ ║
╠════════════════╪═══════════════════════╪═══════════════╪════════════╣
║ │ │ │ ║
║ │ None │ │ ║
║ │<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │ ║
║ │ │ │ ║
║ │ None │ │ ║
║ │<──────────────────────────────────────│ ║
╠════════════════╪═══════════════════════╪═══════════════╪════════════╣
║ [other] │ │ │ ║
║ │ None │ │ ║
║ │<──────────────────────────────────────│ ║
║ │ │ │ ║
║ │ ╔══╧═══════════════╧══╗ ║
║ │ ║This is a long note ░║ ║
║ │ ║over Alice and Last ║ ║
║ │ ╚══╤═══════════════╤══╝ ║
║ │ None │ │ ║
║ │<──────────────────────────────────────│ ║
║ │ │ │ ║
║ │ None │ │ ║
║ │<──────────────────────────────────────│ ║
╚════════════════╪═══════════════════════╪═══════════════╪════════════╝
┌──────┴──────┐ Alice ┌─┴──┐
│Bob on │ ┌─┐ │Last│
│several lines│ ║"│ └────┘
└─────────────┘ └┬┘
┌┼┐
│
┌┴┐