$npx -y skills add github/awesome-copilot --skill plantuml-asciiGenerate 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
| 1 | # PlantUML ASCII Art Diagram Generator |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | 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. |
| 6 | |
| 7 | ## What is PlantUML ASCII Art? |
| 8 | |
| 9 | PlantUML can generate diagrams as plain text (ASCII art) instead of images. This is useful for: |
| 10 | |
| 11 | - Terminal-based workflows |
| 12 | - Git commits/PRs without image support |
| 13 | - Documentation that needs to be version-controlled |
| 14 | - Environments where graphical tools aren't available |
| 15 | |
| 16 | ## Installation |
| 17 | |
| 18 | ```bash |
| 19 | # macOS |
| 20 | brew install plantuml |
| 21 | |
| 22 | # Linux (varies by distro) |
| 23 | sudo apt-get install plantuml # Ubuntu/Debian |
| 24 | sudo yum install plantuml # RHEL/CentOS |
| 25 | |
| 26 | # Or download JAR directly |
| 27 | wget https://github.com/plantuml/plantuml/releases/download/v1.2024.0/plantuml-1.2024.0.jar |
| 28 | ``` |
| 29 | |
| 30 | ## Output Formats |
| 31 | |
| 32 | | Flag | Format | Description | |
| 33 | | ------- | ------------- | ------------------------------------ | |
| 34 | | `-txt` | ASCII | Pure ASCII characters | |
| 35 | | `-utxt` | Unicode ASCII | Enhanced with box-drawing characters | |
| 36 | |
| 37 | ## Basic Workflow |
| 38 | |
| 39 | ### 1. Create PlantUML Diagram File |
| 40 | |
| 41 | ```plantuml |
| 42 | @startuml |
| 43 | participant Bob |
| 44 | actor Alice |
| 45 | |
| 46 | Bob -> Alice : hello |
| 47 | Alice -> Bob : Is it ok? |
| 48 | @enduml |
| 49 | ``` |
| 50 | |
| 51 | ### 2. Generate ASCII Art |
| 52 | |
| 53 | ```bash |
| 54 | # Standard ASCII output |
| 55 | plantuml -txt diagram.puml |
| 56 | |
| 57 | # Unicode-enhanced output (better looking) |
| 58 | plantuml -utxt diagram.puml |
| 59 | |
| 60 | # Using JAR directly |
| 61 | java -jar plantuml.jar -txt diagram.puml |
| 62 | java -jar plantuml.jar -utxt diagram.puml |
| 63 | ``` |
| 64 | |
| 65 | ### 3. View Output |
| 66 | |
| 67 | Output is saved as `diagram.atxt` (ASCII) or `diagram.utxt` (Unicode). |
| 68 | |
| 69 | ## Diagram Types Supported |
| 70 | |
| 71 | ### Sequence Diagram |
| 72 | |
| 73 | ```plantuml |
| 74 | @startuml |
| 75 | actor User |
| 76 | participant "Web App" as App |
| 77 | database "Database" as DB |
| 78 | |
| 79 | User -> App : Login Request |
| 80 | App -> DB : Validate Credentials |
| 81 | DB --> App : User Data |
| 82 | App --> User : Auth Token |
| 83 | @enduml |
| 84 | ``` |
| 85 | |
| 86 | ### Class Diagram |
| 87 | |
| 88 | ```plantuml |
| 89 | @startuml |
| 90 | class User { |
| 91 | +id: int |
| 92 | +name: string |
| 93 | +email: string |
| 94 | +login(): bool |
| 95 | } |
| 96 | |
| 97 | class Order { |
| 98 | +id: int |
| 99 | +total: float |
| 100 | +items: List |
| 101 | +calculateTotal(): float |
| 102 | } |
| 103 | |
| 104 | User "1" -- "*" Order : places |
| 105 | @enduml |
| 106 | ``` |
| 107 | |
| 108 | ### Activity Diagram |
| 109 | |
| 110 | ```plantuml |
| 111 | @startuml |
| 112 | start |
| 113 | :Initialize; |
| 114 | if (Is Valid?) then (yes) |
| 115 | :Process Data; |
| 116 | :Save Result; |
| 117 | else (no) |
| 118 | :Log Error; |
| 119 | stop |
| 120 | endif |
| 121 | :Complete; |
| 122 | stop |
| 123 | @enduml |
| 124 | ``` |
| 125 | |
| 126 | ### State Diagram |
| 127 | |
| 128 | ```plantuml |
| 129 | @startuml |
| 130 | [*] --> Idle |
| 131 | Idle --> Processing : start |
| 132 | Processing --> Success : complete |
| 133 | Processing --> Error : fail |
| 134 | Success --> [*] |
| 135 | Error --> Idle : retry |
| 136 | @enduml |
| 137 | ``` |
| 138 | |
| 139 | ### Component Diagram |
| 140 | |
| 141 | ```plantuml |
| 142 | @startuml |
| 143 | [Client] as client |
| 144 | [API Gateway] as gateway |
| 145 | [Service A] as svcA |
| 146 | [Service B] as svcB |
| 147 | [Database] as db |
| 148 | |
| 149 | client --> gateway |
| 150 | gateway --> svcA |
| 151 | gateway --> svcB |
| 152 | svcA --> db |
| 153 | svcB --> db |
| 154 | @enduml |
| 155 | ``` |
| 156 | |
| 157 | ### Use Case Diagram |
| 158 | |
| 159 | ```plantuml |
| 160 | @startuml |
| 161 | actor "User" as user |
| 162 | actor "Admin" as admin |
| 163 | |
| 164 | rectangle "System" { |
| 165 | user -- (Login) |
| 166 | user -- (View Profile) |
| 167 | user -- (Update Settings) |
| 168 | admin -- (Manage Users) |
| 169 | admin -- (Configure System) |
| 170 | } |
| 171 | @enduml |
| 172 | ``` |
| 173 | |
| 174 | ### Deployment Diagram |
| 175 | |
| 176 | ```plantuml |
| 177 | @startuml |
| 178 | actor "User" as user |
| 179 | node "Load Balancer" as lb |
| 180 | node "Web Server 1" as ws1 |
| 181 | node "Web Server 2" as ws2 |
| 182 | database "Primary DB" as db1 |
| 183 | database "Replica DB" as db2 |
| 184 | |
| 185 | user --> lb |
| 186 | lb --> ws1 |
| 187 | lb --> ws2 |
| 188 | ws1 --> db1 |
| 189 | ws2 --> db1 |
| 190 | db1 --> db2 : replicate |
| 191 | @enduml |
| 192 | ``` |
| 193 | |
| 194 | ## Command-Line Options |
| 195 | |
| 196 | ```bash |
| 197 | # Specify output directory |
| 198 | plantuml -txt -o ./output diagram.puml |
| 199 | |
| 200 | # Process all files in directory |
| 201 | plantuml -txt ./diagrams/ |
| 202 | |
| 203 | # Include dot files (hidden files) |
| 204 | plantuml -txt -includeDot diagrams/ |
| 205 | |
| 206 | # Verbose output |
| 207 | plantuml -txt -v diagram.puml |
| 208 | |
| 209 | # Specify charset |
| 210 | plantuml -txt -charset UTF-8 diagram.puml |
| 211 | ``` |
| 212 | |
| 213 | ## Ant Task Integration |
| 214 | |
| 215 | ```xml |
| 216 | <target name="generate-ascii"> |
| 217 | <plantuml dir="./src" format="txt" /> |
| 218 | </target> |
| 219 | |
| 220 | <target name="generate-unicode-ascii"> |
| 221 | <plantuml dir="./src" format="utxt" /> |
| 222 | </target> |
| 223 | ``` |
| 224 | |
| 225 | ## Tips for Better ASCII Diagrams |
| 226 | |
| 227 | 1. **Keep it simple**: Complex diagrams don't render well in ASCII |
| 228 | 2. **Short labels**: Long text breaks ASCII alignment |
| 229 | 3. **Use Unicode (`-utxt`)**: Better visual quality with box-drawing chars |
| 230 | 4. **Test before sharing**: Verify in terminal with fixed-width font |
| 231 | 5. **Consider alternatives**: For complex diagrams, use Mermaid.js or graphviz |
| 232 | |
| 233 | ## Example Output Comparison |
| 234 | |
| 235 | **Standard ASCII (`-txt`)**: |
| 236 | |
| 237 | ``` |
| 238 | ,---. ,---. |
| 239 | |Bob| |Alice| |
| 240 | `---' `---' |
| 241 | | hello | |
| 242 | |------------->| |
| 243 | | | |
| 244 | | Is it ok? | |
| 245 | |<-- |