PlantUML 文本图表
plantuml-ascii
使用 PlantUML 文本模式生成 ASCII 字符图。适用于用户要求创建 ASCII 图、文本图表、适合终端的图表,或提到 PlantUML ASCII、文本图、字符画图表的情况。支持将 PlantUML 图转换为 ASCII 字符画,创建文本形式的时序图、类图和流程图,以及使用 -utxt 参数生成增强 Unicode 字符图。
介绍来源: author · github · b6483db44fb602654bca6a097185fcaddb305f97 参考来源
作者原文
Generate ASCII art diagrams using PlantUML text mode. Use when user asks to create ASCII diagrams, text-based diagrams, terminal-friendly diagrams, or mentions plantuml ascii, text diagram, ascii art diagram. Supports: Converting PlantUML diagrams to ASCII art, Creating sequence diagrams, class diagrams, flowcharts in ASCII format, Generating Unicode-enhanced ASCII art with -utxt flag
SkillPi 解读
- 能完成的任务
- PlantUML 文本图表
- 适合谁
- 请按作者原文中的适用场景判断。
- 输入和输出
- 以作者完整文档为准;本站未运行验证产物。
- 软件、账号及付费要求
- 使用前按完整文档确认软件、账号、费用及权限;由宿主核对并授权实际文件读写和外部服务。文档引用域名(非运行白名单):github.com 先核实 PlantUML/JVM 支持版本及官方发行摘要;sudo安装由使用者确认。只处理可信图表源,限定输出目录和外部 include/网络权限。 外部工具按官方来源固定版本并单独核验;本站未安装或运行依赖。文件改动、外部发送、密钥和费用仍由使用者在宿主中逐项授权。
- 限制与区别
- 原文中的功能、版本状态和效果描述属于作者陈述;中文为对应翻译。仅核对固定版本及静态附件证据,不保证运行效果、外部服务或兼容性。
- 实测状态
- 未测试
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 27, 30, 31 行 -
账号、密钥或授权
使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。
主文档提及 · 第 87 行 -
管理员或提升权限
确认确有必要再提升权限;不要关闭防护、绕过证书验证或扩大整个系统的访问权限。
主文档提及 · 第 30, 31 行
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- github.com
安全评级与访问范围
caution · 静态证据核验,不代表运行安全保证。
使用前按完整文档确认软件、账号、费用及权限;由宿主核对并授权实际文件读写和外部服务。文档引用域名(非运行白名单):github.com 先核实 PlantUML/JVM 支持版本及官方发行摘要;sudo安装由使用者确认。只处理可信图表源,限定输出目录和外部 include/网络权限。 外部工具按官方来源固定版本并单独核验;本站未安装或运行依赖。文件改动、外部发送、密钥和费用仍由使用者在宿主中逐项授权。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
原始 SKILL.md
---
name: plantuml-ascii
description: "Generate ASCII art diagrams using PlantUML text mode. Use when user asks to create ASCII diagrams, text-based diagrams, terminal-friendly diagrams, or mentions plantuml ascii, text diagram, ascii art diagram. Supports: Converting PlantUML diagrams to ASCII art, Creating sequence diagrams, class diagrams, flowcharts in ASCII format, Generating Unicode-enhanced ASCII art with -utxt flag"
license: MIT
allowed-tools: Bash, Write, Read
---
# PlantUML ASCII Art Diagram Generator
## Overview
Create text-based ASCII art diagrams using PlantUML. Perfect for documentation in terminal environments, README files, emails, or any scenario where graphical diagrams aren't suitable.
## What is PlantUML ASCII Art?
PlantUML can generate diagrams as plain text (ASCII art) instead of images. This is useful for:
- Terminal-based workflows
- Git commits/PRs without image support
- Documentation that needs to be version-controlled
- Environments where graphical tools aren't available
## Installation
```bash
# macOS
brew install plantuml
# Linux (varies by distro)
sudo apt-get install plantuml # Ubuntu/Debian
sudo yum install plantuml # RHEL/CentOS
# Or download JAR directly
wget https://github.com/plantuml/plantuml/releases/download/v1.2024.0/plantuml-1.2024.0.jar
```
## Output Formats
| Flag | Format | Description |
| ------- | ------------- | ------------------------------------ |
| `-txt` | ASCII | Pure ASCII characters |
| `-utxt` | Unicode ASCII | Enhanced with box-drawing characters |
## Basic Workflow
### 1. Create PlantUML Diagram File
```plantuml
@startuml
participant Bob
actor Alice
Bob -> Alice : hello
Alice -> Bob : Is it ok?
@enduml
```
### 2. Generate ASCII Art
```bash
# Standard ASCII output
plantuml -txt diagram.puml
# Unicode-enhanced output (better looking)
plantuml -utxt diagram.puml
# Using JAR directly
java -jar plantuml.jar -txt diagram.puml
java -jar plantuml.jar -utxt diagram.puml
```
### 3. View Output
Output is saved as `diagram.atxt` (ASCII) or `diagram.utxt` (Unicode).
## Diagram Types Supported
### Sequence Diagram
```plantuml
@startuml
actor User
participant "Web App" as App
database "Database" as DB
User -> App : Login Request
App -> DB : Validate Credentials
DB --> App : User Data
App --> User : Auth Token
@enduml
```
### Class Diagram
```plantuml
@startuml
class User {
+id: int
+name: string
+email: string
+login(): bool
}
class Order {
+id: int
+total: float
+items: List
+calculateTotal(): float
}
User "1" -- "*" Order : places
@enduml
```
### Activity Diagram
```plantuml
@startuml
start
:Initialize;
if (Is Valid?) then (yes)
:Process Data;
:Save Result;
else (no)
:Log Error;
stop
endif
:Complete;
stop
@enduml
```
### State Diagram
```plantuml
@startuml
[*] --> Idle
Idle --> Processing : start
Processing --> Success : complete
Processing --> Error : fail
Success --> [*]
Error --> Idle : retry
@enduml
```
### Component Diagram
```plantuml
@startuml
[Client] as client
[API Gateway] as gateway
[Service A] as svcA
[Service B] as svcB
[Database] as db
client --> gateway
gateway --> svcA
gateway --> svcB
svcA --> db
svcB --> db
@enduml
```
### Use Case Diagram
```plantuml
@startuml
actor "User" as user
actor "Admin" as admin
rectangle "System" {
user -- (Login)
user -- (View Profile)
user -- (Update Settings)
admin -- (Manage Users)
admin -- (Configure System)
}
@enduml
```
### Deployment Diagram
```plantuml
@startuml
actor "User" as user
node "Load Balancer" as lb
node "Web Server 1" as ws1
node "Web Server 2" as ws2
database "Primary DB" as db1
database "Replica DB" as db2
user --> lb
lb --> ws1
lb --> ws2
ws1 --> db1
ws2 --> db1
db1 --> db2 : replicate
@enduml
```
## Command-Line Options
```bash
# Specify output directory
plantuml -txt -o ./output diagram.puml
# Process all files in directory
plantuml -txt ./diagrams/
# Include dot files (hidden files)
plantuml -txt -includeDot diagrams/
# Verbose output
plantuml -txt -v diagram.puml
# Specify charset
plantuml -txt -charset UTF-8 diagram.puml
```
## Ant Task Integration
```xml
<target name="generate-ascii">
<plantuml dir="./src" format="txt" />
</target>
<target name="generate-unicode-ascii">
<plantuml dir="./src" format="utxt" />
</target>
```
## Tips for Better ASCII Diagrams
1. **Keep it simple**: Complex diagrams don't render well in ASCII
2. **Short labels**: Long text breaks ASCII alignment
3. **Use Unicode (`-utxt`)**: Better visual quality with box-drawing chars
4. **Test before sharing**: Verify in terminal with fixed-width font
5. **Consider alternatives**: For complex diagrams, use Mermaid.js or graphviz
## Example Output Comparison
**Standard ASCII (`-txt`)**:
```
,---. ,---.
|Bob| |Alice|
`---' `---'
| hello |
|------------->|
| |
| Is it ok? |
|<-------------|
| |
```
**Unicode ASCII (`-utxt`)**:
```
┌─────┐ ┌─────┐
│ Bob │ │Alice│
└─────┘ └─────┘
│ hello │
│─────────────>│
│ │
│ Is it ok? │
│<─────────────│
│ │
```
## Quick Reference
```bash
# Create sequence diagram in ASCII
cat > seq.puml << 'EOF'
@startuml
Alice -> Bob: Request
Bob --> Alice: Response
@enduml
EOF
plantuml -txt seq.puml
cat seq.atxt
# Create with Unicode
plantuml -utxt seq.puml
cat seq.utxt
```
## Troubleshooting
**Problem**: Garbled Unicode characters
- **Solution**: Ensure terminal supports UTF-8 and has proper font
**Problem**: Diagram looks misaligned
- **Solution**: Use fixed-width font (Courier, Monaco, Consolas)
**Problem**: Command not found
- **Solution**: Install PlantUML or use Java JAR directly
**Problem**: Output file not created
- **Solution**: Check file permissions, ensure PlantUML has write access
版权与许可声明
MIT License Copyright GitHub, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
用户讨论