Plantuml

Plantuml

Plantuml

下载安装

下载plantuml.jar或者根据源里面安装

同目录运行 java -jar plantuml.jar -extractstdlib 安装标准库

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
➜  ~ ls -l stdlib 
总计 0
drwxr-xr-x 1 liuliancao liuliancao    28  2月 1日 18:06 archimate
drwxr-xr-x 1 liuliancao liuliancao   572  2月 1日 18:06 aws
drwxr-xr-x 1 liuliancao liuliancao   918  2月 1日 18:06 awslib14
drwxr-xr-x 1 liuliancao liuliancao   510  2月 1日 18:06 azure
drwxr-xr-x 1 liuliancao liuliancao   190  2月 1日 18:06 c4
drwxr-xr-x 1 liuliancao liuliancao    44  2月 1日 18:06 classy
drwxr-xr-x 1 liuliancao liuliancao   572  2月 1日 18:06 classy-c4
drwxr-xr-x 1 liuliancao liuliancao  1784  2月 1日 18:06 cloudinsight
drwxr-xr-x 1 liuliancao liuliancao    42  2月 1日 18:06 cloudogu
drwxr-xr-x 1 liuliancao liuliancao    32  2月 1日 18:06 domainstory
drwxr-xr-x 1 liuliancao liuliancao   332  2月 1日 18:06 elastic
drwxr-xr-x 1 liuliancao liuliancao   404  2月 1日 18:06 kubernetes
drwxr-xr-x 1 liuliancao liuliancao 29968  2月 1日 18:06 logos
drwxr-xr-x 1 liuliancao liuliancao 74052  2月 1日 18:06 material
drwxr-xr-x 1 liuliancao liuliancao   154  2月 1日 18:06 office
drwxr-xr-x 1 liuliancao liuliancao   506  2月 1日 18:06 osa
drwxr-xr-x 1 liuliancao liuliancao   154  2月 1日 18:06 tupadr3

然后你就可以include测试了

1
2
3
4
5
6
@startuml
!include <awslib14/AWSCommon>
!include <awslib14/Compute/all.puml>

listsprites
@enduml

C4 related

C4 model官网 https://c4model.com/

由于我们是plantuml,所以使用C4-plantuml 对应网站为 https://github.com/plantuml-stdlib/C4-PlantUML

示例


@startuml C4_Elements
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml

Person(personAlias, "Label", "Optional Description")
Container(containerAlias, "Label", "Technology", "Optional Description")
System(systemAlias, "Label", "Optional Description")

Rel(personAlias, containerAlias, "Label", "Optional Technology")
@enduml

./demo1.png◎ ./demo1.png

重要命令

listsprites

列出当前可以展示的icons

@startuml
listsprites
@enduml

注释

使用 ' 注释 进行注释

连接线

-> 横连 --> 竖着连

布局

together 让这些item 平齐

常用模板

框+图

@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

' Users
osa_user_green_developer1: <$osa_user_green_developer>
osa_user_green_operations: <$osa_user_green_operations>
osa_user_green_business_manager: <$osa_user_green_business_manager>

' Devices
osa_desktop: <$osa_desktop>
osa_laptop: <$osa_laptop>
osa_iPhone: <$osa_iPhone>
osa_server: <$osa_server>

' Network
osa_device_wireless_router: <$osa_device_wireless_router>
osa_hub: <$osa_hub>
osa_firewall: <$osa_firewall>
osa_osa_cloud: <$osa_cloud>

footer %filename() rendered with PlantUML version %version()\nThe Hitchhiker’s Guide to PlantUML
@enduml