plantuml语法
时间: 2023-07-01 15:17:03 浏览: 122
PlantUML 是一种基于文本的图形化工具,可以通过简单易懂的语法来绘制各种类型的图形,包括时序图、用例图、类图、流程图等。下面是一些常用的 PlantUML 语法示例:
1. 时序图
```
@startuml
actor User
participant "First Class" as A
participant "Second Class" as B
participant "Last Class" as C
User -> A: DoWork
activate A
A -> B: Create Request
activate B
B -> C: DoWork
activate C
C --> B: WorkDone
destroy C
B --> A: Request Created
deactivate B
A --> User: Done
deactivate A
@enduml
```
2. 用例图
```
@startuml
left to right direction
actor User
User -> (Use the application) : <<Use>>
(Use the application) --> (View weather) : <<Include>>
(Use the application) --> (View map) : <<Include>>
(Use the application) --> (View news) : <<Include>>
@enduml
```
3. 类图
```
@startuml
class Car {
-make: string
-model: string
-year: int
+getMake(): string
+getModel(): string
+getYear(): int
}
class Driver {
-name: string
-age: int
+getName(): string
+getAge(): int
}
Driver -> Car: drives
@enduml
```
4. 流程图
```
@startuml
start
if (condition A) then (yes)
:Action 1;
elseif (condition B) then (yes)
:Action 2;
else (no)
:Action 3;
endif
:Action 4;
end
@enduml
```
这些语法示例只是 PlantUML 的冰山一角,更多用法可以参考官方文档。
阅读全文