PlantUml可以在很多工具上使用,這里使用了atom和vscode
1泛烙、下載atom
當(dāng)網(wǎng)站https://atom.io/下載
安裝后需要安裝兩個(gè)插件
atom下 File -> Settings -> Install
安裝:
language-plantuml
plantuml-viewer
不要安裝plantuml-preview理卑,因?yàn)檫@個(gè)使用還需要安裝plantuml.jar
對文本格式的代碼,按ctrl+alt+p就顯示圖形
2蔽氨、PlantUml參考文檔
3藐唠、遇到過的問題
3.1、中文亂碼
需要設(shè)置
plantuml-viewer
atom下 File -> Settings -> Packages
找到plantuml-viewer后選擇settings鹉究,在Charset中填寫 UTF-8
3.2中捆、出現(xiàn)Syntax Error
參考文檔http://plantuml.com/zh/sequence-diagram
中在參與者中使用非字母符號部分:
vm_service_impl.go->native/vm_impl.go: RunContract
activate native/vm_impl.go
改成
vm_service_impl.go->"native/vm_impl.go" as NativeVmImpl: RunContract
activate NativeVmImpl
4、如果在vscode上安裝
需要參考https://marketplace.visualstudio.com/items?itemName=jebbs.plantuml
以管理員的身份運(yùn)行cmd坊饶,并執(zhí)行下面的命令
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
choco install plantuml
然后在vscode上安裝PlantUML插件,編寫代碼后殴蓬,保存為.pu文件匿级,按alt+D執(zhí)行顯示預(yù)覽
如果要保存文件蟋滴,在文件內(nèi)容上右鍵鼠標(biāo),選擇Export Current Diagram痘绎,會自動保存到當(dāng)前項(xiàng)目\out\test\目錄