PlantUML with VSCode

PlantUML with VSCode

Posted by Kuo on March 15, 2018

PlantUML with VSCode

PlantUML is a component that allows to quickly write:

  • Sequence diagram
  • Usecase diagram
  • Class diagram
  • Activity diagram
  • Component diagram
  • State diagram
  • Object diagram
  • Deployment diagram
  • Timing diagram

For PlantUML itself, it is a Jar package, but with VSCode, it can be even more powerful. VSCode has a PlantUML extension supporting review, export for multiple file-formats(png, svg etc.)

Get Started

Prerequisite

I think everyone know how to download, install and setup Java, and Graphviz, you need to add its dot.exe into environment variables

Environment Variable Name Value
GRAPHVIZ_DOT C:\Software\Graphviz\bin\dot.exe
How to install

launch VSCode Quick Open(Ctrl + P), paste the following command, and press enter.

ext install plantuml
Basic Shortcut
Short Cut Operation
Alt + D Preview
Ctrl + Shift + P Export
Alt + Shift + F Auto Format
Example
@startuml Encrypt
{
    styles: blue
}

package Int_LogViewerLib {
    class AccessLogViewerViewModel {

    }
}

package  Infrastructure.LoggingUtils.Xml {
     AccessLogViewerViewModel --> LogWatcher

    class LogEncryptor {
        + string EncryptData(string data)
        + string DecryptData(string data)
    }

    class EncryptLayoutRendererWrapper {
        + bool Encrypt
        # override string Transform(string text)
    }

    class LogWatcher {
        - bool performRead()
    }

    LogWatcher --> LogEncryptor: decrpyt data
    EncryptLayoutRendererWrapper --> LogEncryptor: encrypt data
}

package  NLog {
    EncryptLayoutRendererWrapper --|> WrapperLayoutRendererBase
}
@enduml

Encrypt