大多数说明建议您可以使用python使用:python -m plantuml example_diagram.txt
生成PlantUML图。我想创建一个python脚本,在创建时生成多个PlantUML图,这样我就可以立即更新一组完整的图,而不必运行多个命令
以下文件用于生成PlantUML图:
example_flow.txt
内容:' http://tonyballantyne.com/graphs.html#orgheadline19
' http://graphviz.org/doc/info/shapes.html
' Indicate the direction of the flowchart
left to right direction
' Give a block the variable name 'first' and define starting point as (*)
(*) --> "The first block" as first
first --> "A" as A
' Give the block a variable name s.t. you can just use its variable name in the next blocks
--> "D" as D
first --> "B" as B
--> D
first --> "C" as C
--> D
' Define end point as (*)
D --> (*)
Graphviz_example.txt
内容:' http://tonyballantyne.com/graphs.html#orgheadline19
' http://graphviz.org/doc/info/shapes.html
digraph summary{
// initialize the variable blocks
start [label="Start with a Node"]
next [label="Choose your shape", shape=box]
warning [label="Don't go overboard", color=Blue, fontcolor=Red,fontsize=24,style=filled, fillcolor=green,shape=octagon]
end [label="Draw your graph!", shape=box, style=filled, fillcolor=yellow]
// Indicate the direction of the flowchart
rankdir=LR; // Rank direction left to right
// Create the connections
start->next
start->warning
next->end [label="Getting Better...", fontcolor=darkblue]
}
如何从单个python脚本创建这些图
为同一目录中的2个文件生成
创建名为
create_diagrams.py
的python文件,其内容如下:然后运行它,例如在anaconda中使用Python3.6运行命令:
python create_diagrams.py
为目录中的所有文件生成
还可以为名为
Diagrams
的目录中的所有.txt
文件生成图表,其中包括:注释
此实现需要活动的internet连接,因为您需要PlantUML服务器为您生成图形。要在本地编译,还可以下载PlantUML软件的
.jar
文件,并从python调用该文件来进行计算。在the question of this post中给出了一个更详细的例子相关问题 更多 >
编程相关推荐