PlantUML Snippets
Source: PlantUML Command Line, PlantUML Hitch Hikers Guide, https://plantuml.com/, PlantUML Code Blocks in Babel
# Generate diagrams in PNG format for each filejava -jar plantuml.jar file1 file2 file3
# If plantuml CLI is installed, can substitute java -jar plantuml.jar with plantumlplantuml -tpng mydiagram.puml# Required on Windowsplantuml -tpng path/to/mydiagram.puml
# Helpplantuml -h
# Open GUI to select directoryplantuml -gui
# Render diagram in default format PNGplantuml diagram1.puml
# Rend diagrams in directoryplantuml path/to/diagrams
# Generate an ASCII Art file using Unicode charactersplantuml -ttxt mydiagram.puml
# Display all standard libraries availablejava -jar plantuml.jar -stdlib
PlantUML Syntax
Section titled “PlantUML Syntax”For available sprites (icons, boxes), see plantuml-stdlib and https://plantuml.com/stdlib for example cloud icons, K8s, security icons.
For C4 examples, see https://crashedmind.github.io/PlantUMLHitchhikersGuide/C4/C4Stdlib.html
@startuml
!define osaPuml https://raw.githubusercontent.com/Crashedmind/PlantUML-opensecurityarchitecture2-icons/master!include osaPuml/Common.puml!include osaPuml/User/all.puml!include osaPuml/Hardware/all.puml!include osaPuml/Misc/all.puml!include osaPuml/Server/all.puml!include osaPuml/Site/all.puml
'. List available sprites and their name for use in PlantUML in current librarylistsprites'. will list osa sprites in this file
'. comments'. Mary is a Developer in the Product team. She has a Windows 10 PC and an Android phone.'. Bob is a Manager in the Accounts team. He has Mac and an iPhone.'. Diagram uses OpenSecurityArchitecture PlantUML library
Title Network diagram
' Userstogether {osa_user_green_developer(Mary, "Mary", "Product team", "Developer")osa_user_green_operations(Ivan, "Ivan", "IT Team", "Server Admin")osa_user_green_business_manager(Bob, "Bob", "Accounts team", "Manager")note left : Look at Bob}' Devicestogether {osa_desktop(pc, "192.168.1.10", "Windows 10", "PC")osa_laptop(mac, "192.168.1.12", "Mac", "Mac")osa_iPhone(iphone, "Dynamic IP", "iPhone 11", "Phone")osa_iPhone(android, "Dynamic IP", "Android 10", "Phone")osa_server(server, "192.168.1.100", "Ubuntu Server 20.04 LTS", "Server")}
' Network
osa_device_wireless_router(wifiAP, "192.168.1.1", "Network")osa_hub(hub, "Office hub", "Hub")osa_firewall(firewall, "51.37.24.103", "Network")osa_cloud(cloud, "Internet", "Network")
Mary --> pc: source codeMary --> android: social media
Bob --> mac: financial infoBob --> iphone: phone calls
'. Connection with commentIvan --> server: configuration
iphone --> wifiAPandroid --> wifiAPwifiAP --> hub
server --> hubmac --> hubpc --> hub
hub --> firewall
firewall --> cloud
legend1. my legend text2. second legend textendlegend
'. Complex legendlegend |= Color |= Type |= Description | | <size:11><back:#Red>Mary </back></size>| <color:Red><$osa_user_green_developer*.4></color> | Mary details... This is a stdlib sprite | | <size:11><back:#DarkGreen>Ivan </back></size>| <color:DarkGreen><$osa_user_green_operations*.4></color> | Ivan details... | | <size:11><back:#Orange>Bob </back></size>| <color:Orange><$osa_user_green_business_manager*.4></color> | Bob details... | | <size:11><back:#Purple>Box </back></size>| <color:Purple><&box></color> | A Box. This is an openiconic sprite |endlegend
footer %filename() rendered with PlantUML version %version()\nExample from The Hitchhiker’s Guide to PlantUML@enduml
Entity Diagram Relationships
Section titled “Entity Diagram Relationships”Type Symbol-----------------------------Zero or One |o--Exactly One ||--Zero or Many }o--One or Many }|--
Emacs org-mode Snippets for plantuml-mode
Section titled “Emacs org-mode Snippets for plantuml-mode”Output to media directory and output source block in exports and activate inlineimages in org-mode and output image file
<hit C-c ' here to open a plantuml-mode buffer and C-' to return to this org document>
Alice -> Bob: test
Output to temporary file
ASCII text output
Bob -> Alice : Hello World!