golang使用PlantUML生成uml

安装golang sdk

PlantUML Web Server

开源工具,使用简单的文字描述画UML图。 (plantuml.com)

安装

1
2
3
4
go get github.com/jfeliu007/goplantuml/parser
go get github.com/jfeliu007/goplantuml/cmd/goplantuml
cd $GOPATH/src/github.com/jfeliu007/goplantuml/cmd/goplantuml/
go install

安装到$GOPATH\bin

运行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# 单个目录
goplantuml -recursive path/to/gofiles > diagram_file_name.puml

# 多个目录
goplantuml -recursive path/to/gofiles path/to/gofiles2 > diagram_file_name.puml

goplantuml.exe \
-recursive \
-aggregate-private-members \
-show-aggregations \
-show-aliases \
-show-compositions \
-show-connection-labels \
-show-implementations \
-show-options-as-note ./ > dd.puml


# 参数
Usage of goplantuml:
-aggregate-private-members
Show aggregations for private members. Ignored if -show-aggregations is not used.
-hide-connections
hides all connections in the diagram
-hide-fields
hides fields
-hide-methods
hides methods
-ignore string
comma separated list of folders to ignore
-notes string
Comma separated list of notes to be added to the diagram
-output string
output file path. If omitted, then this will default to standard output
-recursive
walk all directories recursively
-show-aggregations
renders public aggregations even when -hide-connections is used (do not render by default)
-show-aliases
Shows aliases even when -hide-connections is used
-show-compositions
Shows compositions even when -hide-connections is used
-show-connection-labels
Shows labels in the connections to identify the connections types (e.g. extends, implements, aggregates, alias of
-show-implementations
Shows implementations even when -hide-connections is used
-show-options-as-note
Show a note in the diagram with the none evident options ran with this CLI
-title string
Title of the generated diagram
-hide-private-members
Hides all private members (fields and methods)


goplantuml的用法:
-aggregate-private-members
显示私有成员的聚合。如果不使用 -show-aggregations,则忽略。
-hide-connections
隐藏图中的所有连接
-hide-fields
隐藏字段
-hide-methods
隐藏方法
-ignore string
要忽略的文件夹的逗号分隔列表
-notes string
要添加到图表中的以逗号分隔的注释列表
-output string
输出文件路径。如果省略,则默认为标准输出
-recursive
递归遍历所有目录
-show-aggregations
即使使用 -hide-connections 也会呈现公共聚合(默认情况下不呈现)
-show-aliases
即使使用 -hide-connections 也显示别名
-show-compositions
即使使用 -hide-connections 也显示组合
-show-connection-labels
在连接中显示标签以识别连接类型(例如扩展、实现、聚合、别名)
-show-implementations
即使使用 -hide-connections 也显示实现
-show-options-as-note
在下方显示图例
-title string
生成图的标题
-hide-private-members
隐藏所有私有成员(字段和方法)

预览

在vscode中预览

安装PlantUML插件(使用该插件需要安装jdk) alt+d

在intellij IDEA中预览

安装PlantUML integration插件