plantuml-syntax
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePlantUML Syntax Reference
PlantUML语法参考
Overview
概述
PlantUML is a Java-based tool that creates diagrams from text descriptions. It supports comprehensive UML diagrams and many non-UML diagram types.
Key advantages:
- Most comprehensive diagram support (15+ types)
- Mature C4 model integration with icons/sprites
- Extensive customization options
- Battle-tested (since 2009)
Requirements:
- Java Runtime Environment (JRE)
- GraphViz (for some diagram types)
- Or use Docker:
docker run -p 8080:8080 plantuml/plantuml-server
PlantUML是一款基于Java的工具,可通过文本描述生成图表。它支持全面的UML图表以及多种非UML图表类型。
核心优势:
- 支持最全面的图表类型(15+种)
- 成熟的C4模型集成,包含图标/精灵图
- 丰富的自定义选项
- 久经考验(自2009年起)
运行要求:
- Java运行环境(JRE)
- GraphViz(部分图表类型需要)
- 或使用Docker:
docker run -p 8080:8080 plantuml/plantuml-server
Diagram Types Quick Reference
图表类型速查
UML Diagrams
UML图表
| Type | Keywords | Best For |
|---|---|---|
| Sequence | | Interactions, API flows, protocols |
| Use Case | | Requirements, user stories |
| Class | | OOP design, domain models |
| Activity | | Workflows, processes |
| Component | | System structure |
| Deployment | | Infrastructure, deployment |
| State | | State machines |
| 类型 | 关键字 | 适用场景 |
|---|---|---|
| 时序图 | | 交互流程、API流程、协议 |
| 用例图 | | 需求、用户故事 |
| 类图 | | 面向对象设计、领域模型 |
| 活动图 | | 工作流、流程 |
| 组件图 | | 系统结构 |
| 部署图 | | 基础设施、部署 |
| 状态图 | | 状态机 |
Non-UML Diagrams
非UML图表
| Type | Keywords | Best For |
|---|---|---|
| JSON | | JSON structure visualization |
| YAML | | YAML structure visualization |
| Wireframe | | UI mockups |
| Gantt | | Project timelines |
| MindMap | | Hierarchical ideas |
| WBS | | Work breakdown |
| ER | | Database schemas |
| C4 | | Software architecture |
| 类型 | 关键字 | 适用场景 |
|---|---|---|
| JSON图 | | JSON结构可视化 |
| YAML图 | | YAML结构可视化 |
| 线框图 | | UI原型 |
| 甘特图 | | 项目时间线 |
| 思维导图 | | 层级化想法 |
| WBS图 | | 工作分解结构 |
| ER图 | | 数据库 schema |
| C4图 | 包含C4的 | 软件架构 |
Basic Syntax
基础语法
All PlantUML diagrams are wrapped in start/end tags:
plantuml
@startuml
' Your diagram code here
@endumlComments:
- Single line:
' This is a comment - Block:
/' This is a block comment '/
Title and captions:
plantuml
@startuml
title My Diagram Title
caption This is a caption
header Page Header
footer Page Footer
' Diagram content
@enduml所有PlantUML图表都需要包裹在开始/结束标签中:
plantuml
@startuml
' 你的图表代码写在这里
@enduml注释:
- 单行注释:
' 这是一条注释 - 块注释:
/' 这是块注释 '/
标题与说明文字:
plantuml
@startuml
title 我的图表标题
caption 这是说明文字
header 页面页眉
footer 页面页脚
' 图表内容
@endumlQuick Reference Card
速查卡片
Sequence
时序图
plantuml
@startuml
participant A
participant B
A -> B: Message
A <-- B: Response
@endumlplantuml
@startuml
participant A
participant B
A -> B: 消息
A <-- B: 响应
@endumlClass
类图
plantuml
@startuml
class Name {
- private
+ public
+ method()
}
A <|-- B : extends
A *-- B : contains
@endumlplantuml
@startuml
class Name {
- private
+ public
+ method()
}
A <|-- B : extends
A *-- B : contains
@endumlActivity
活动图
plantuml
@startuml
start
:Action;
if (condition?) then (yes)
:True path;
else (no)
:False path;
endif
stop
@endumlplantuml
@startuml
start
:操作;
if (条件?) then (是)
:真分支;
else (否)
:假分支;
endif
stop
@endumlState
状态图
plantuml
@startuml
[*] --> State1
State1 --> State2 : event
State2 --> [*]
@endumlplantuml
@startuml
[*] --> State1
State1 --> State2 : 事件
State2 --> [*]
@endumlComponent
组件图
plantuml
@startuml
[Component1] --> [Component2]
database DB
Component2 --> DB
@endumlplantuml
@startuml
[Component1] --> [Component2]
database DB
Component2 --> DB
@endumlReferences
参考资料
For detailed syntax and complete examples, see:
| Reference | Content | When to Load |
|---|---|---|
| sequence.md | Participants, arrows, activation, groups, notes | Creating sequence diagrams |
| class.md | Classes, visibility, relationships, cardinality | Creating class diagrams |
| activity.md | Conditions, swimlanes, fork/join | Creating activity diagrams |
| state-component.md | State machines, components, deployment | Creating state/component diagrams |
| c4.md | C4 context, container, component diagrams | Creating C4 architecture diagrams |
| special-diagrams.md | ER, JSON, MindMap, Gantt | Creating non-UML diagrams |
| styling-setup.md | Skinparams, themes, installation | Customizing diagrams, setting up PlantUML |
如需详细语法和完整示例,请查看:
| 参考文档 | 内容 | 适用场景 |
|---|---|---|
| sequence.md | 参与者、箭头、激活、分组、注释 | 创建时序图 |
| class.md | 类、可见性、关系、基数 | 创建类图 |
| activity.md | 条件、泳道、分支/合并 | 创建活动图 |
| state-component.md | 状态机、组件、部署 | 创建状态图/组件图 |
| c4.md | C4上下文、容器、组件图 | 创建C4架构图 |
| special-diagrams.md | ER图、JSON图、思维导图、甘特图 | 创建非UML图表 |
| styling-setup.md | Skinparams、主题、安装 | 自定义图表、PlantUML设置 |
File Extensions
文件扩展名
| Extension | Description |
|---|---|
| Standard PlantUML file |
| Alternative extension |
| Short extension |
| Include file |
| 扩展名 | 说明 |
|---|---|
| 标准PlantUML文件 |
| 替代扩展名 |
| 短扩展名 |
| 包含文件 |
Test Scenarios
测试场景
Scenario 1: Creating a sequence diagram
场景1:创建时序图
Query: "Create a PlantUML sequence diagram for user authentication"
Expected: Skill activates, provides sequence syntax with participants, arrows, and alt/else blocks
查询: "为用户认证流程创建PlantUML时序图"
预期结果: 工具激活,提供包含参与者、箭头、alt/else块的时序图语法
Scenario 2: Creating a class diagram
场景2:创建类图
Query: "Generate a PlantUML class diagram for an e-commerce domain"
Expected: Skill activates, provides class syntax with relationships and cardinality
查询: "为电商领域生成PlantUML类图"
预期结果: 工具激活,提供包含关系和基数的类图语法
Scenario 3: Creating a C4 diagram
场景3:创建C4图
Query: "Create a C4 container diagram in PlantUML"
Expected: Skill activates, directs to c4.md reference for includes and syntax
Last Updated: 2025-12-28
PlantUML Version: 1.2024.6
查询: "用PlantUML创建C4容器图"
预期结果: 工具激活,引导查看c4.md参考文档获取包含文件和语法
最后更新: 2025-12-28
PlantUML版本: 1.2024.6
Version History
版本历史
- v1.1.0 (2025-12-28): Refactored to progressive disclosure - extracted content to references/
- v1.0.0 (2025-12-26): Initial release
- v1.1.0 (2025-12-28): 重构为渐进式披露 - 将内容拆分至references/目录
- v1.0.0 (2025-12-26): 初始版本