使用PlantUml VSCode 快速生成UML
1.PlantUML
https://plantuml.com/zh/
一个UML的DSL语言, 网站有快速的显示地方, 语法也很简单.
https://plantuml.com/zh/running
有各种工具
目前推荐VS Code打开
2.GraphViz
绘图的
http://www.graphviz.org/Download_windows.php
需要设置一个路径
GRAPHVIZ_DOT
xxx\Graphviz\bin\dot.exe
3.VSCode 需要安装两个插件: PlantUML 和 Graphviz Preview
点击 VSCode 左下角齿轮按钮进入设置,在用户设置脚本中添加 “graphviz-preview.dotPath”: “D:/program files/Graphviz/bin/dot.exe” 并保存设置:
到这里如果你是想在VSCode 里面想自己写PlantUML, 预览, 导出都是可以的.
之后的是c# 自动导出的.
4.netCore 3.0
下面的工具需要用到这个,
https://dotnet.microsoft.com/download/dotnet-core/3.0
- c#代码生成UML
https://github.com/pierre3/PlantUmlClassDiagramGenerator
windows 命令行中安装
dotnet tool install --global PlantUmlClassDiagramGenerator --version 1.2.0
之后就可以通过命令来吧C#代码生成plantUML
puml-gen InputPath [OutputPath] [-dir] [-public | -ignore IgnoreAccessibilities] [-excludePaths ExcludePathList] [-createAssociation]
InputPath: (Required) Sets a input source file or directory name.
OutputPath: (Optional) Sets a output file or directory name.
If you omit this option, plantuml files are outputted to same directory as the input files.
-dir: (Optional) Specify when InputPath and OutputPath are directory names.
-public: (Optional) If specified, only public accessibility members are output.
-ignore: (Optional) Specify the accessibility of members to ignore, with a comma separated list.
-excludePaths: (Optional) Specify the exclude file and directory.
Specifies a relative path from the “InputPath”, with a comma separated list.
-createAssociation: (Optional) Create object associations from references of fields and properites.
-allInOne: (Optional) Only if -dir is set: copy the output of all diagrams to file include.puml (this allows a PlanUMLServer to render it).
examples
puml-gen C:\Source\App1\ClassA.cs -public
puml-gen C:\Source\App1 C:\PlantUml\App1 -dir -ignore Private,Protected -createAssociation -allInOne
puml-gen C:\Source\App1 C:\PlantUml\App1 -dir -excludePaths bin,obj,Properties