叶面图形预处理器。
foliantcontrib.graphviz的Python项目详细描述
叶子图预处理器
Graphviz是一个开源的图形可视化工具。这个预处理器在源代码中转换graphviz图定义,并在项目构建期间动态地将它们转换为图像。
安装
$ pip install foliantcontrib.graphviz
配置
要启用预处理器,请将graphviz
添加到项目配置中的preprocessors
部分:
preprocessors:-graphviz
预处理器有许多选项:
preprocessors:-graphviz:cache_dir:!path.diagramscachegraphviz_path:dotengine:dotformat:pngas_image:trueparams:...
cache_dir
:生成图表的目录的路径。它可以是相对于项目根目录的路径,也可以是全局路径;您可以使用~/
快捷方式。
To save time during build, only new and modified diagrams are rendered. The generated images are cached and reused in future builds.
graphviz_path
:graphviz启动程序的路径。默认情况下,假设在PATH
中有dot
命令,但是如果graphviz使用另一个命令启动,或者如果dot
启动程序安装在自定义位置,则可以在此处定义它。
engine
:用于处理关系图源的布局引擎。可用引擎:(circo
,dot
,fdp
,neato
,osage
,patchwork
,sfdp
twopi
)。默认值:dot
format
:图表图像的输出格式。可用格式:tons of them。默认值:png
as_image
:如果true
-将scheme作为md image插入到文档中。如果false
-将graphviz生成的文件直接插入到文档中(对于svg
图像可能很方便)。默认值:true
params
:传递给图像生成命令的参数:
preprocessors:
- graphviz:
params:
Gdpi: 100
To see the full list of params, run the command that launches Graphviz, with
-?
command line option.
用法
若要在标记源中插入关系图定义,请将其括在<<graphviz>...</graphviz>
标记之间:
Here’s a diagram: <<graphviz> a -> b </graphviz>
可以在标记选项中设置任何参数。标记选项的优先级高于配置选项,因此您可以覆盖特定关系图的某些值,同时在配置中设置默认值。
标记还有两个独占选项:caption
选项-关系图图像的标记标题和src
-关系图源的路径(相对于当前文件)。
If
src
tag option is supplied, tag body is ignored. Diagram source is loaded from external file.
Diagram with a caption: <<graphviz caption="Deployment diagram" params="Earrowsize: 0.5" src="diags/sample.gv"> </graphviz>
Note that command params listed in the
params
option are stated in YAML format. Remember that YAML is sensitive to indentation so for several params it is more suitable to use JSON-like mappings:{key1: 1, key2: 'value2'}
.