Donate225Patreon111


Ascii Art

Il est possible de générer des diagrammes de séquence avec de l'ASCII Art.

@startuml
participant Bob
actor Alice

Bob -> Alice : hello
Alice -> Bob : Is it ok?
@enduml

Il suffit de rajouter l'option -txt dans la ligne de commande ou bien d'utiliser le paramètre format dans la tâche ANT correspondante :

<target name="main">
  <plantuml dir="./src" format="txt" />
</target>

Les fichiers générés ont une extension .atxt. ("a" comme ASCII art : de façon à ne PAS écraser des fichiers .txt déjà existant!). Voici le résultat:

                      ,-.
                      `-'
                      /|\
     ,---.             |
     |Bob|            / \
     `-+-'           Alice
       |    hello      |
       |-------------->|
       |               |
       |  Is it ok?    |
       |<- - - - - - - |
     ,-+-.           Alice
     |Bob|            ,-.
     `---'            `-'
                      /|\
                       |
                      / \

Unicode

The default txt format uses only plain ASCII characters. It is possible to use few extended Unicode characters to have a slightly better result. You should use the -utxt flag in the command line, or the utxt format in the ANT task.

                      ┌─┐
                      ║"│
                      └┬┘
                      ┌┼┐
     ┌───┐             │
     │Bob│            ┌┴┐
     └─┬─┘           Alice
       │    hello      │
       │──────────────>│
       │               │
       │  Is it ok?    │
       │<─ ─ ─ ─ ─ ─ ─ │
     ┌─┴─┐           Alice
     │Bob│            ┌─┐
     └───┘            ║"│
                      └┬┘
                      ┌┼┐
                       │
                      ┌┴┐

They are two drawbacks of using utxt:

Complexe Diagram

You can even try complex example if you wish.

@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

Result

                                             ,-.
                                             `-'
               ,-------------.               /|\
               |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|               `-'            `----'
               `-------------'               /|\
                                              |
                                             / \

Same example using 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│               ║"│            └────┘
               └─────────────┘               └┬┘
                                             ┌┼┐
                                              │
                                             ┌┴┐