天天看點

PlantUML安裝和使用什麼是PlantUML首頁安裝簡單使用

plantuml是一個快速建立uml圖形的元件,plantuml支援的圖形有:

sequence diagram,

use case diagram,

class diagram,

activity diagram,

component diagram,

state diagram,

object diagram,

wireframe graphical interface

PlantUML安裝和使用什麼是PlantUML首頁安裝簡單使用

ascii art格式:

plantuml依賴<code>graphviz</code>,故先安裝:

sublime text 的內建使用的是<code>sublime_diagram_plugin</code>因為預設的包管理中沒有,是以需要自己添加源。

使用 <code>command-shift-p</code> 打開 <code>command palette</code>

等待添加完成後再次使用<code>command-shift-p</code>打開<code>command palette</code>

輸入<code>install package</code>找到<code>package control:install package</code>

等待清單加載完畢,輸入<code>diagram</code>找到<code>sublime_diagram_plugin</code> 安裝

重新開機<code>sublime text</code>

重新開機後可以在<code>preferences -&gt; packages setting</code>看到<code>diagram</code>,預設綁定的渲染快捷鍵是<code>super + m</code>也就是<code>command + m</code>如果不沖突直接使用即可。

為了簡化使用,可以在 sublime 裡配置個快捷鍵。打開 <code>preferences -&gt; key binding - user</code>,添加一個快捷鍵:

上面的代碼配置成按住 <code>alt + d</code> 來生成 plantuml 圖檔,你可以修改成你自己喜歡的按鍵。

使用的話比較簡單,繪圖的内容需要包含在<code>@startuml</code>和<code>@enduml</code>中,不然會報錯。

在文本中輸入以下内容:

按<code>command + m</code>會在目前工作目錄下生成這個圖檔檔案,同時自動彈出視窗顯示如下圖檔。

PlantUML安裝和使用什麼是PlantUML首頁安裝簡單使用

将其儲存為basic.txt之後,可以在指令行運作:

這樣會在目前路徑生成了名為 basic.svg 的圖檔。