PlantUML通用命令
1、注释
1.1、简单注释
所有以 ' 开始的都是一个的注释
js
@startuml
'Line comments use a single apostrophe
@enduml
1.2、块状注释
块状注释使用 C 风格的注释,除了用一撇一捺代替', 然后你也可以把注释放在几行上,用/' 开始,'/结束。
js
@startuml
/'
many lines comments
here
'/
@enduml
也可以在同一行中放置块状注释
js
@startuml
/' case 1 '/ A -> B : AB-First step
B -> C : BC-Second step
/' case 2 '/ D -> E : DE-Third step
@enduml

2、缩放
- 可以使用缩放命令缩放生成的图像。
- 可以使用数字或分数来定义比例因子。您还可以指定任一宽度或高度(像素)
- 也可以同时给出宽度和高度:图像被缩放以适应指定尺寸
- scale 1.5
- scale 2/3
- scale 200 width
- scale 200 height
- scale 200*100
- scale max 300*200
- scale max 1024 width
- scale max 800 height
js
@startuml
scale 180*90
Bob->Alice : hello
@enduml

3、标题
使用 title 关键字添加标题。你可以在标题描述中使用 \n 添加新行。
js
@startuml
skinparam titleBorderRoundCorner 15
skinparam titleBorderThickness 2
skinparam titleBorderColor red
skinparam titleBackgroundColor Aqua-CadetBlue
title Simple communication\nexample
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
@enduml

js
@startuml
title
<u>Simple</u> communication example
on <i>several</i> lines and using <back:cadetblue>creole tags</back>
end title
Alice -> Bob: Authentication Request
Bob -> Alice: Authentication Response
@enduml

4、图片标题
使用 caption 关键字在图像下放置一个标题.
js
@startuml
caption figure 1
Alice -> Bob: Hello
@enduml

5、页眉和页脚
- 可以使用
header和footer命令在生成的图中增加页眉和页脚。 - 可以选择指定
center,left或right关键字使页眉或页脚实现居中、左对齐和右对齐。 - 和标题一样,页眉或页脚内容可以在多行中定义,而且同样可以在页眉或页脚中输入一些 HTML 代码。
js
@startuml
Alice -> Bob: Authentication Request
header
<font color=red>Warning:</font>
Do not use in production.
endheader
center footer Generated for demonstration
@enduml

6、图例说明
legend和end legend作为关键词,用于配置一个图例 (legend)- 支持可选地使用
left,right,center为这个图例指定对齐方式.
js
@startuml
Alice -> Bob : Hello
legend right
Short
legend
endlegend
@enduml

7、图标示例
7.1、活动图
js
@startuml
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
start
:Hello world;
:This is defined on
several **lines**;
stop
@enduml

7.2、Archimate
js
@startuml
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
archimate #Technology "VPN Server" as vpnServerA <<technology-device>>
rectangle GO #lightgreen
rectangle STOP #red
rectangle WAIT #orange
@enduml

7.3、类图
js
@startuml
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
a -- b
@enduml

7.4、组件图
js
@startuml
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
node n
(u) -> [c]
@enduml

7.5、甘特图
js
@startgantt
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
[t] lasts 5 days
@endgantt

7.6、对象图
js
@startgantt
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
object user {
name = "Dummy"
id = 123
}
@enduml

7.7、思维导图
js
@startmindmap
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
* r
** d1
** d2
@endmindmap

7.8、Network (nwdiag)
js
@startuml
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
nwdiag {
network inet {
web01 [shape = cloud]
}
}
@enduml

7.9、序列图
js
@startuml
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
a->b
@enduml

7.10、状态图
js
@startuml
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
[*] --> State1
State1 -> State2
@enduml

7.11、定时图
js
@startuml
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
robust "Web Browser" as WB
concise "Web User" as WU
@0
WU is Idle
WB is Idle
@100
WU is Waiting
WB is Processing
@300
WB is Waiting
@enduml

7.12、工作分解结构(WBS)
js
@startwbs
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
* r
** d1
** d2
@endwbs

7.13、线框图
js
@startsalt
header some header
footer some footer
title My title
caption This is caption
legend
The legend
end legend
{+
Login | "MyName "
Password | "**** "
[Cancel] | [ OK ]
}
@endsalt
