Install
openclaw skills install @holdyounger/plantuml-skill-2用 PlantUML 文本语法绘制 UML 图:时序图、类图、活动图、用例图、状态图、组件图、部署图、思维导图、甘特图等。
openclaw skills install @holdyounger/plantuml-skill-2使用 PlantUML 基于文本的语法生成 UML 图和其他图表类型。所有图表都以 @startuml 开始,以 @enduml 结束。
@startuml
' 图表内容
@enduml
注释:单行用 ',块注释用 /' ... '/。
title — 添加标题caption — 图片下方标题header / footer — 页眉/页脚(可加 left/center/right)legend ... end legend — 图例scale 1.5 / scale 200 width / scale 200*100 — 缩放left to right direction — 改变方向**...**、斜体 //...//、列表等)participant Alice
actor Bob
boundary Wall
control C
entity E
database DB
collections Col
queue Q
用 as 定义别名:participant Alice as A。
用 order 设定顺序:participant Alice order 10。
A -> B — 实线箭头A --> B — 虚线箭头A <- B — 反向A ->> B — 实线开放箭头A -\ B — 仅起始端箭头A \\- B — 仅末端箭头A x> B — 末端带XA -> B : 消息文本 — 带标签activate A / deactivate Aautoactivate on — 自动激活destroy A — 销毁alt/else — 条件分支opt — 可选loop — 循环par — 并行break — 中断critical — 关键group 标题 — 自定义分组note left/right/over — 注释A -> B : <text> 中可使用 \n 换行ref over A, B — 引用delay — 延迟divider — 分隔线class ClassName {
+ publicMethod()
- privateField: Type
# protectedField: Type
~ packageField: Type
{static} staticField
{abstract} abstractMethod()
}
interface InterfaceName
abstract class AbstractClass
enum EnumName {
VALUE1
VALUE2
}
annotation AnnotationName
可见性:+ public, - private, # protected, ~ package。
A --|> B — 继承(A继承B)A ..|> B — 实现(A实现B接口)A --> B — 关联A --* B — 组合A ..* B — 聚合A o-- B — 聚合(反向)A ..> B — 依赖A -- B — 实线连接A .. B — 虚线连接关系标签:A --> "1" B : "包含","*" --> "1" 多重性。
<<interface>> InterfaceName
<<abstract>> AbstractClass
<<enumeration>> EnumName
<<annotation>> AnnotationName
类内注释:note left, note right, note top, note bottom。
package "包名" {
class A
class B
}
@startuml
start
:动作1;
:动作2;
stop
@enduml
动作以 : 开始,; 结束。隐式自动连接。
if (条件?) then (yes)
:动作A;
else (no)
:动作B;
endif
elseif 支持多分支。!pragma useVerticalIf on 切换垂直模式。
switch (变量?)
case (值1)
:动作1;
case (值2)
:动作2;
endswitch
repeat
:动作;
repeat while (条件?)
while (条件?) is (标签)
:动作;
endwhile
fork
:分支1;
fork again
:分支2;
end fork
split
:路径1;
split again
:路径2;
end split
|泳道A|
:动作1;
|泳道B|
:动作2;
泳道别名:|#<颜色>|<别名>| <标题>。
partition "分区名" {
:动作1;
:动作2;
}
也支持 group, package, rectangle, card。
kill / detach — 终止/分离break — 打断循环note — 注释(可用 floating 浮动)-> 可加文本和颜色actor 用户 as U
usecase "登录" as UC1
usecase "查看资料" as UC2
U --> UC1
U --> UC2
UC1 ..> UC2 : <<include>>
actor 关键字或冒号语法 :用户名:usecase 关键字或括号 (用例名)as 定义别名rectangle "系统名" { ... } 分组--> 关联..> 依赖..> : <<include>> 包含..> : <<extend>> 扩展--|> 继承[*] --> State1
State1 --> State2 : 事件
State2 --> [*]
state Composite {
state Sub1
state Sub2
Sub1 --> Sub2
}
<<fork>> / <<join>> — 分叉/合并<<choice>> — 选择<<entryPoint>> / <<exitPoint>> — 入口/出口[H] / [H*] — 历史/深历史状态用 -- 或 || 分隔并发区域。
note left of, note right of, note top of, note bottom of, note on link。
component "组件A" as A
component [组件B]
interface "接口" as I
A --|> I
A ..> B : 使用
component 或 [名称]interface 或 ()名称as 别名.. 虚线-- 实线--> 箭头package, node, folder, frame, cloud, database。
port, portIn, portOut 关键字。
actor 用户
component 组件
interface 接口
usecase 用例
node 服务器 {
component 应用
}
database 数据库
短格式::a: (actor), [c] (component), ()i (interface), (u) (usecase)。
与组件图相同的连接类型,支持线条样式、颜色、粗细。
所有元素可嵌套:node, package, folder, frame, cloud, database。
allowmixing 或 allow_mixing 指令允许在类图/对象图中混用部署元素。
analog — 模拟信号(连续,线性插值)binary — 二进制信号clock — 时钟信号(需 period,可选 pulse/offset)concise — 简明表示robust — 状态线表示@startuml
clock clk period 2
binary b
robust r
@0
b is high
r is state1
@5
b is low
r is state2
@enduml
@N — 绝对时间@+N / @-N — 相对时间@N as :名称 — 锚点is — 定义状态@startmindmap
+ 中心主题
++ 一级分支
+++ 二级分支
-- 左侧分支
--- 二级左侧
@endmindmap
运算符:+ 右侧, - 左侧, * 右侧多级, _ 左侧多级。
@startmindmap
* 中心
** 分支1
*** 子分支
@endmindmap
@startmindmap
- 中心
-- 分支
--- 子分支
@endmindmap
多行文本用 : 和 ; 包围。
@startgantt
projectstart 2024-01-01
[任务A] lasts 5 days
[任务B] lasts 3 days
[任务B] starts at [任务A]'s end
@endgantt
[任务] lasts N days — 持续时间[任务] starts N days after [任务B]'s end — 相对开始[任务] ends at [任务B]'s end — 相对结束[任务] happens at 2024-01-15 — 绝对日期then — 连续任务[任务] as T — 短名称is xx% completed — 完成度[里程碑] happens at 2024-02-01 — 里程碑projectstart — 项目开始日期2024-01-01 to 2024-12-31 — 日期范围saturday are closed / sunday are closed — 关闭日printscale daily/weekly/monthly/quarterly/yearly — 尺度注意:skinparam 已废弃,建议迁移到
<style>CSS 样式。
skinparam backgroundColor transparent
skinparam monochrome true
skinparam shadowing false
skinparam defaultFontName Helvetica
skinparam classFontColor red
skinparam classFontSize 10
skinparam ArrowHeadColor none
skinparam componentStyle rectangle
嵌套写法:
skinparam class {
FontColor red
FontSize 10
FontName Helvetica
}
!$var = "value"
!$i = 42
!$a ?= "default"
!if ($var == "value")
...
!else
...
!endif
!while ($i > 0)
...
!endwhile
!function $name($param)
!return $param + "!"
!endfunction
!include file.iuml
!include_many file.iuml
!include_once file.iuml
!includesub file.puml!SECTION
%date(), %now(), %darken("red", 20), %chr(65), %intval("42"), %file_exists("path") 等。
支持标准颜色名(red, blue, green 等)和 RGB 码(#FF0000)。transparent 仅用于背景。
内联颜色样式:#color;line:color;line.[bold|dashed|dotted];text:color。
java -jar plantuml.jar file.puml-tpng(默认)、-tsvg、-tpdf、-tlatex!pragma 指令可控制渲染行为