如何使用plantUML生成go项目的UML图?(mac)
生活随笔
收集整理的這篇文章主要介紹了
如何使用plantUML生成go项目的UML图?(mac)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
0 前言
當時看想一下項目的UML圖,在網上找了好幾篇文章,試了很久都么有成功,我也不知道是不是他們教程有問題,后面自己琢磨,在github上找了幾個項目,試了一下,終于ok了。
1 安裝goplantuml項目
這個項目主要用于生成項目的*.puml文件的,這一步很重要。
go get github.com/jfeliu007/goplantuml/parser go get github.com/jfeliu007/goplantuml/cmd/goplantuml cd $GOPATH/src/github.com/jfeliu007/goplantuml go install ./...使用上述命令安裝,安裝之后就可以使用了。
用法
# 選擇多個文件生成,也可以直接一個目錄 goplantuml [-recursive] path/to/gofiles path/to/gofiles2 goplantuml [-recursive] path/to/gofiles path/to/gofiles2 > diagram_file_name.puml選項:
Usage of goplantuml:-aggregate-private-membersShow aggregations for private members. Ignored if -show-aggregations is not used.-hide-connectionshides all connections in the diagram-hide-fieldshides fields-hide-methodshides methods-ignore stringcomma separated list of folders to ignore-notes stringComma separated list of notes to be added to the diagram-output stringoutput file path. If omitted, then this will default to standard output-recursivewalk all directories recursively-show-aggregationsrenders public aggregations even when -hide-connections is used (do not render by default)-show-aliasesShows aliases even when -hide-connections is used-show-compositionsShows compositions even when -hide-connections is used-show-connection-labelsShows labels in the connections to identify the connections types (e.g. extends, implements, aggregates, alias of-show-implementationsShows implementations even when -hide-connections is used-show-options-as-noteShow a note in the diagram with the none evident options ran with this CLI-title stringTitle of the generated diagram-hide-private-membersHides all private members (fields and methods)選項很多,用的多的就兩個:-output和-recursive,設置*.puml文件輸出路徑和是否遞歸生成。
例如:goplantuml $GOPATH/src/github.com/jfeliu007/goplantuml/parser
生成了*.puml文件之后,我們需要選擇工具進行生成圖片。
注意:使用前確認是否安裝Graphviz 。
2 生成UML圖片
有兩種方法。
使用plantuml.jar文件生成
- 下載plantuml.jar文件,百度可以找到官網
- 如果沒有安裝java環境自行安裝
生成圖片命令:java -jar plantuml.jar *.puml
這樣就可以生成UML圖片了。
注意: 如果圖片太大,需要修改圖片大小和分辨率。
參考:https://blog.csdn.net/SweetTool/article/details/108208953
使用工具
可以選擇vscode或者goland作為生成工具,安裝plantuml插件即可。
總結
以上是生活随笔為你收集整理的如何使用plantUML生成go项目的UML图?(mac)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 这 56 个代码注释让我笑吐了
- 下一篇: Redis 16 大应用场景,竟然这么多