puml-plantuml
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePUML-PlantUML Expert Skill
PUML-PlantUML专家工具
Deep PlantUML knowledge (all 27 chapters from official reference) + cross-platform
local rendering + image→PUML reverse engineering. Offline rendering. Any OS. No
assumed paths. Full Python + Java + PlantUML auto-detection and installation.
具备深厚的PlantUML知识(覆盖官方参考指南全部27个章节)+跨平台本地渲染+图像转PUML逆向工程能力。离线渲染,支持任意操作系统,无需预设路径,可自动检测并安装Python、Java和PlantUML。
Quick Decision Tree
快速决策树
User request
├── "Create/draw a diagram from description" → § Generate PUML
├── "Convert image/screenshot to PUML" → § Image → PUML
├── "Render/preview/generate image from code" → § Render Locally
├── "Fix/debug my PUML" → § Diagnose & Fix
└── "Explain syntax / how do I..." → references/syntax-quick-ref.md用户请求
├── "根据描述创建/绘制图表" → § 生成PUML
├── "将图像/截图转换为PUML" → § 图像转PUML
├── "从代码渲染/预览/生成图像" → § 本地渲染
├── "修复/调试我的PUML" → § 诊断与修复
└── "讲解语法 / 如何操作..." → 参考references/syntax-quick-ref.md§ First Run — Bootstrap from Zero
§ 首次运行——从零开始引导安装
The bootstrap scripts require no pre-installed tools — they install
Python → Java → PlantUML in the correct order. Run once per machine.
引导安装脚本无需任何预安装工具——它们会按正确顺序安装Python→Java→PlantUML。每台机器只需运行一次。
macOS / Linux
macOS / Linux
bash
bash scripts/bootstrap.sh # install everything
bash scripts/bootstrap.sh --verify # install + test renderbash
bash scripts/bootstrap.sh # 安装所有组件
bash scripts/bootstrap.sh --verify # 安装并测试渲染Windows (PowerShell — built into Windows 10/11)
Windows(PowerShell——Windows 10/11内置)
powershell
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\scripts\bootstrap.ps1
.\scripts\bootstrap.ps1 -Verifypowershell
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\scripts\bootstrap.ps1
.\scripts\bootstrap.ps1 -VerifyIf Python is already available
若已安装Python
bash
python3 scripts/render.py --detect # show what's detected
python3 scripts/setup.py # install Java + PlantUML
python3 scripts/setup.py --java # ensure Java only
python3 scripts/setup.py --jar # force JAR download
python3 scripts/setup.py --verify # install + test render
python3 scripts/render.py --install-hint # show manual stepsWhat gets installed:
| Component | macOS | Linux | Windows |
|---|---|---|---|
| Python 3.9+ | brew | apt/dnf/pacman/snap | winget/choco/scoop |
| Java JRE 11+ | brew cask temurin | apt/dnf/pacman | winget Temurin/Zulu |
| PlantUML | brew | apt/dnf/pacman/snap | winget/choco/scoop |
| Fallback | — | | |
Java detected from: , PATH, macOS ,
Azul/Zulu (), Temurin, Homebrew OpenJDK, SDKMAN, .
$JAVA_HOME/usr/libexec/java_homezulu*/usr/lib/jvm/*bash
python3 scripts/render.py --detect # 显示已检测到的组件
python3 scripts/setup.py # 安装Java + PlantUML
python3 scripts/setup.py --java # 仅确保Java安装
python3 scripts/setup.py --jar # 强制下载JAR包
python3 scripts/setup.py --verify # 安装并测试渲染
python3 scripts/render.py --install-hint # 显示手动安装步骤将安装的组件:
| 组件 | macOS | Linux | Windows |
|---|---|---|---|
| Python 3.9+ | brew | apt/dnf/pacman/snap | winget/choco/scoop |
| Java JRE 11+ | brew cask temurin | apt/dnf/pacman | winget Temurin/Zulu |
| PlantUML | brew | apt/dnf/pacman/snap | winget/choco/scoop |
| 备用方案 | — | | |
Java检测路径:、PATH、macOS 、Azul/Zulu()、Temurin、Homebrew OpenJDK、SDKMAN、。
$JAVA_HOME/usr/libexec/java_homezulu*/usr/lib/jvm/*§ Generate PUML from Description
§ 根据描述生成PUML
Step 1 — Identify diagram type:
| Keywords in request | Type | Tag |
|---|---|---|
| sequence of calls, API flow, messages | Sequence | |
| classes, OOP, inheritance, methods | Class | |
| process, workflow, flowchart, steps | Activity (new) | |
| architecture, services, components | Component | |
| database, schema, tables, entities | ER | |
| states, lifecycle, status transitions | State | |
| use cases, actors, user stories | Use Case | |
| objects, instances, runtime snapshot | Object | |
| timing, signals, waveforms | Timing | |
| brainstorm, concept map, topics | MindMap | |
| project timeline, schedule, milestones | Gantt | |
| work breakdown, project phases | WBS | |
| UI form, wireframe, mockup | Salt | |
| JSON data structure | JSON | |
| YAML data structure | YAML | |
| network topology, servers, subnets | nwdiag | |
| enterprise architecture, ArchiMate | Archimate | |
| math formula, equation, LaTeX | Maths | |
| ASCII art diagram | Ditaa | |
Step 2 — Generate using the full syntax in .
Always include: a line, , labels on all arrows.
references/syntax-quick-ref.mdtitleskinparam shadowing falseStep 3 — Write, validate & render:
bash
cat > /tmp/diagram.puml << 'PUML'
@startuml
title My Diagram
... generated code ...
@enduml
PUML
python3 scripts/render.py /tmp/diagram.puml --check # validate
python3 scripts/render.py /tmp/diagram.puml -f svg -o /tmp/ # render步骤1——确定图表类型:
| 请求中的关键词 | 类型 | 标签 |
|---|---|---|
| 调用序列、API流程、消息 | 序列图 | |
| 类、面向对象、继承、方法 | 类图 | |
| 流程、工作流、流程图、步骤 | 活动图(新版) | |
| 架构、服务、组件 | 组件图 | |
| 数据库、模式、表、实体 | ER图 | |
| 状态、生命周期、状态转换 | 状态图 | |
| 用例、参与者、用户故事 | 用例图 | |
| 对象、实例、运行时快照 | 对象图 | |
| 时序、信号、波形 | 时序图 | |
| 头脑风暴、概念图、主题 | 思维导图 | |
| 项目时间线、进度、里程碑 | 甘特图 | |
| 工作分解、项目阶段 | 工作分解结构 | |
| UI表单、线框图、原型 | Salt | |
| JSON数据结构 | JSON | |
| YAML数据结构 | YAML | |
| 网络拓扑、服务器、子网 | nwdiag | |
| 企业架构、ArchiMate | Archimate | |
| 数学公式、方程式、LaTeX | 数学公式 | |
| ASCII艺术图表 | Ditaa | |
步骤2——生成代码:使用中的完整语法。需始终包含:行、、所有箭头的标签。
references/syntax-quick-ref.mdtitleskinparam shadowing false步骤3——编写、验证并渲染:
bash
cat > /tmp/diagram.puml << 'PUML'
@startuml
title My Diagram
... 生成的代码 ...
@enduml
PUML
python3 scripts/render.py /tmp/diagram.puml --check # 验证
python3 scripts/render.py /tmp/diagram.puml -f svg -o /tmp/ # 渲染§ Image → PUML (Reverse Engineering)
§ 图像转PUML(逆向工程)
- View the image — use the tool or examine the upload
view - Identify the diagram type —
references/image-to-puml.md - Extract elements — names, labels, arrows, relationships, cardinality
- Generate PUML — reproduce faithfully, correct arrow types
- Validate & render — compare against original; refine if needed
Visual analysis guide:references/image-to-puml.md
- 查看图像——使用工具或检查上传的文件
view - 确定图表类型——参考
references/image-to-puml.md - 提取元素——名称、标签、箭头、关系、基数
- 生成PUML——忠实还原,修正箭头类型
- 验证并渲染——与原图对比;如有需要则优化
视觉分析指南:references/image-to-puml.md
§ Render Locally
§ 本地渲染
Use — auto-detects binary vs JAR+Java, any OS.
scripts/render.pybash
undefined使用——自动检测二进制文件或JAR+Java,支持任意操作系统。
scripts/render.pybash
undefinedmacOS / Linux
macOS / Linux
python3 scripts/render.py diagram.puml # PNG
python3 scripts/render.py diagram.puml -f svg -o ./output/ # SVG
python3 scripts/render.py diagram.puml -f pdf -o ./output/ # PDF
cat diagram.puml | python3 scripts/render.py --stdin -f svg -n "name" -o /tmp/
python3 scripts/render.py diagram.puml # 生成PNG
python3 scripts/render.py diagram.puml -f svg -o ./output/ # 生成SVG
python3 scripts/render.py diagram.puml -f pdf -o ./output/ # 生成PDF
cat diagram.puml | python3 scripts/render.py --stdin -f svg -n "name" -o /tmp/
Windows
Windows
py scripts\render.py diagram.puml
py scripts\render.py diagram.puml -f svg -o .\output\
Direct CLI (if `plantuml` is in PATH):
```bash
plantuml -tsvg diagram.puml
plantuml -tpng -o ./output/ *.puml
plantuml -checkonly diagram.pumlPresent the output file to the user after rendering using .
present_filesFull options, env vars, formats, troubleshooting:references/local-rendering.md
py scripts\render.py diagram.puml
py scripts\render.py diagram.puml -f svg -o .\output\
直接使用CLI(若`plantuml`已在PATH中):
```bash
plantuml -tsvg diagram.puml
plantuml -tpng -o ./output/ *.puml
plantuml -checkonly diagram.puml渲染完成后,使用向用户展示输出文件。
present_files完整选项、环境变量、格式、故障排除:references/local-rendering.md
§ Diagnose & Fix PUML
§ 语法速查表(超精简版)
bash
python3 scripts/render.py diagram.puml --check| Error | Cause | Fix |
|---|---|---|
| Missing wrapper | Add |
| Typo or wrong diagram type | Check syntax-quick-ref.md |
Arrow | ASCII required | Use |
| Forward reference | Declare before use |
| Graphviz error | | |
| PlantUML not found | Not installed | |
| Java not detected | Non-standard JDK | Set |
| Python not found | Python missing | |
| Unicode broken | Charset issue | |
完整参考(全部27章,2700+行):references/syntax-quick-ref.md
序列图箭头:
-> 同步调用 --> 响应/虚线
->> 细线箭头 -->> 细虚线箭头
->x 消息丢失 ->o 开放箭头
<-> 双向箭头 ->+ 激活 -->- 取消激活
[-> 传入箭头 ->] 传出箭头类图关系:
<|-- 继承 <|.. 实现
o-- 聚合 *-- 组合
--> 依赖 ..> 使用
-- 关联 --() 棒棒糖(提供的接口)
"1" *-- "0..*" : label (带基数和标签)ER图基数(乌鸦脚表示法):
|| 恰好一个 o| 零或一个
o{ 零或多个 |{ 一个或多个所有@start标签:
@startuml 大多数图表
@startmindmap 思维导图
@startgantt 甘特图
@startwbs 工作分解结构
@startsalt 线框图
@startjson JSON展示
@startyaml YAML展示
@startmath AsciiMath公式
@startlatex LaTeX公式
@startditaa Ditaa ASCII艺术图通用格式化:
plantuml
title My Title
skinparam shadowing false
skinparam monochrome true
!theme cerulean
left to right direction
!pragma layout smetana ' 无需Graphviz§ Syntax Cheatsheet (Ultra-Quick)
完整图表覆盖(PDF全部27章)
Full reference (all 27 chapters, 2700+ lines):references/syntax-quick-ref.md
Sequence arrows:
-> sync --> response/dashed
->> thin -->> thin dashed
->x lost ->o open arrowhead
<-> bidirectional ->+ activate -->- deactivate
[-> incoming ->] outgoingClass relationships:
<|-- inheritance <|.. realization
o-- aggregation *-- composition
--> dependency ..> usage
-- association --() lollipop (provided interface)
"1" *-- "0..*" : label (with cardinality and label)ER cardinality (crow's foot):
|| exactly one o| zero or one
o{ zero or more |{ one or moreAll @start tags:
@startuml most diagrams
@startmindmap mind maps
@startgantt gantt charts
@startwbs work breakdown
@startsalt wireframes
@startjson JSON display
@startyaml YAML display
@startmath AsciiMath
@startlatex LaTeX formula
@startditaa Ditaa ASCII artUniversal formatting:
plantuml
title My Title
skinparam shadowing false
skinparam monochrome true
!theme cerulean
left to right direction
!pragma layout smetana ' no Graphviz needed| 章节 | 类型 | 说明 |
|---|---|---|
| 1 | 序列图 | 完整支持:箭头、分组、激活、注释、自动编号、主框架、并行、构造型/标记点、锚点、包含、隐藏页脚 |
| 2 | 用例图 | 完整支持:参与者、扩展/包含、注释、包、业务用例、JSON覆盖 |
| 3 | 类图 | 完整支持:可见性、构造型、标记点、泛型、棒棒糖、继承/实现关键字、隐藏/显示/移除、$tags、命名空间 |
| 4 | 对象图 | 实例、关系、映射、关联对象 |
| 5 | 活动图(旧版) | 旧版 |
| 6 | 活动图(新版) | 开始/结束、if/else/elseif、switch/case、while、repeat、分叉、拆分、泳道、SDL形状、goto/label、连接器、条件样式 |
| 7 | 组件图 | 组件、接口、球窝连接、分组、端口、隐藏未链接元素 |
| 8 | 部署图 | 所有元素类型、嵌套、端口、圆角、方向 |
| 9 | 状态图 | 嵌套、并发、分叉/合并、历史状态、选择、引脚、扩展、链接注释、内联颜色 |
| 10 | 时序图 | 鲁棒性、简洁性、二进制、时钟、模拟;相对时间、锚点、高亮 |
| 11 | JSON | 展示、高亮、样式、极简示例 |
| 12 | YAML | 展示、高亮、别名、Creole标记 |
| 13 | 网络图(nwdiag) | 网络、节点、地址、分组、精灵图、对等网络 |
| 14 | 线框图(Salt) | 所有组件:按钮、输入框、下拉菜单、单选框、复选框、网格、树、标签页、分组框、滚动框 |
| 15 | ArchiMate | archimate关键字、连接点、宏、标准库集成 |
| 16 | 甘特图 | 任务、约束、里程碑、颜色、完成百分比、超链接、休息日、缩放、比例 |
| 17 | 思维导图 | OrgMode和Markdown语法、左侧分支、多根节点、颜色、方向 |
| 18 | 工作分解结构 | OrgMode语法、方向、颜色、箭头、自动换行 |
| 19 | 数学公式 | AsciiMath( |
| 20 | ER图(信息工程) | 实体、属性、主键/外键标记、乌鸦脚关系 |
| 21 | 通用命令 | 注释、缩放、标题、说明、页眉、页脚、图例、新页面、主框架、附录、编译指示 |
| 22 | Creole标记 | 粗体、斜体、等宽、删除线、下划线、波浪线;列表、标题、表格、链接、表情、HTML标签、Unicode |
| 23 | 精灵图 | 定义十六进制精灵图、内联SVG精灵图、从标准库导入、OpenIconic、Font Awesome |
| 24 | Skinparam样式 | 全元素Skinparam支持 + 现代 |
| 25 | 预处理 | 变量、条件、while/循环、过程、函数、默认参数、无引号参数、关键字参数、导入、子部分、主题、定义、内置函数( |
| 26 | Unicode | 原生UTF-8、 |
| 27 | 标准库 | ArchiMate、AWS、Azure、C4、Kubernetes、Elastic、GCP、CloudOgu、Tupadr3/FontAwesome、EDGY |
| — | Ditaa | |
Complete Diagram Coverage (All 27 Chapters from PDF)
参考文件
| Ch | Type | Notes |
|---|---|---|
| 1 | Sequence | Full: arrows, groups, activation, notes, autonumber, mainframe, parallel, stereotypes/spots, anchors, encompass, hide footbox |
| 2 | Use Case | Full: actors, extends/include, notes, packages, business UC, JSON overlay |
| 3 | Class | Full: visibility, stereotypes, spots, generics, lollipop, extends/implements keywords, hide/show/remove, $tags, namespaces |
| 4 | Object | Instances, relations, maps, association objects |
| 5 | Activity (Legacy) | Old |
| 6 | Activity (New) | start/stop, if/else/elseif, switch/case, while, repeat, fork, split, swimlanes, SDL shapes, goto/label, connectors, condition style |
| 7 | Component | Components, interfaces, ball-socket, grouping, ports, hide unlinked |
| 8 | Deployment | All element types, nesting, ports, round corners, orientation |
| 9 | State | Nested, concurrent, fork/join, history, choice, pin, expansion, note on link, inline colour |
| 10 | Timing | robust, concise, binary, clock, analog; relative time, anchors, highlights |
| 11 | JSON | Display, highlight, styles, minimal examples |
| 12 | YAML | Display, highlight, aliases, Creole |
| 13 | Network (nwdiag) | Networks, nodes, addresses, grouping, sprites, peer networks |
| 14 | Wireframe (Salt) | All widgets: button, input, dropdown, radio, checkbox, grid, tree, tabs, group box, scrollbox |
| 15 | Archimate | archimate keyword, junctions, macros, StdLib integration |
| 16 | Gantt | Tasks, constraints, milestones, colours, completion %, hyperlinks, closed days, zoom, scale |
| 17 | MindMap | OrgMode and Markdown syntax, left branches, multiroot, colours, direction |
| 18 | WBS | OrgMode syntax, direction, colours, arrows, word wrap |
| 19 | Maths | AsciiMath ( |
| 20 | ER (Info Engineering) | Entities, attributes, PK/FK markers, crow's foot relations |
| 21 | Common Commands | comments, scale/zoom, title, caption, header, footer, legend, newpage, mainframe, appendix, pragma |
| 22 | Creole | Bold, italic, mono, strike, underline, wave; lists, headings, tables, links, emoji, HTML tags, Unicode |
| 23 | Sprites | Define hex sprites, inline SVG sprites, import from StdLib, OpenIconic, Font Awesome |
| 24 | Skinparam | Full per-element skinparam + modern |
| 25 | Preprocessing | Variables, conditions, while/loop, procedures, functions, default args, unquoted, keyword args, includes, subparts, themes, define, builtins ( |
| 26 | Unicode | Native UTF-8, |
| 27 | StdLib | ArchiMate, AWS, Azure, C4, Kubernetes, Elastic, GCP, CloudOgu, Tupadr3/FontAwesome, EDGY |
| — | Ditaa | |
| 文件 | 内容 |
|---|---|
| 2700+行——全部27章的完整语法 |
| 图像转PUML逆向工程的视觉分析指南 |
| 安装设置、CLI参数、格式、环境变量、故障排除 |
Reference Files
脚本说明
| File | Content |
|---|---|
| 2700+ lines — complete syntax for all 27 chapters |
| Visual analysis guide for image→PUML reverse engineering |
| Setup, CLI flags, formats, env vars, troubleshooting |
| 脚本 | 用途 |
|---|---|
| macOS/Linux入门首选——安装Python→Java→PlantUML(无依赖) |
| Windows入门首选——PowerShell 5+,无需依赖 |
| Python环境设置:检测/安装Java + PlantUML;同时报告Python状态 |
| 跨平台渲染工具:自动检测Python/二进制文件/JAR/Java |
Scripts
—
| Script | Purpose |
|---|---|
| Start here — macOS/Linux — installs Python→Java→PlantUML (no deps) |
| Start here — Windows — PowerShell 5+, no deps required |
| Python setup: detect/install Java + PlantUML; also reports Python |
| Cross-platform render: auto-detects Python/binary/JAR/Java |
—