用于树叶的美人鱼图预处理器。
foliantcontrib.mermaid的Python项目详细描述
用于树叶的美人鱼图预处理器
Mermaid是一个开源的图表可视化工具。此预处理器在项目生成期间将标记文件中的美人鱼图定义实时转换为图像。
安装
$ pip install foliantcontrib.mermaid
请不要使用此预处理器,您还需要安装美人鱼和美人鱼cli:
$ npm install mermaid # installs locally
$ npm install mermaid.cli
配置
要启用预处理器,请将mermaid
添加到项目配置中的preprocessors
部分:
preprocessors:-mermaid
预处理器有许多选项:
preprocessors:-mermaid:cache_dir:!path.diagramscachemermaid_path:!pathnode_modules/.bin/mmdcformat:svgparams:...
cache_dir
:生成图表的目录的路径。它可以是相对于项目根目录的路径,也可以是全局路径;您可以使用~/
快捷方式。
To save time during build, only new and modified diagrams are rendered. The generated images are cached and reused in future builds.
mermaid_path
:mermaid cli二进制文件的路径。如果在本地安装美人鱼,则需要此参数。默认值:mmdc
。
format
:生成的图像格式。可用:svg
,png
,pdf
。默认值svg
。
params
:传递给图像生成命令的参数:
preprocessors:
- mermaid:
params:
theme: forest
To see the full list of available params, run
mmdc -h
or check here.
用法
若要在标记源中插入关系图定义,请将其括在<<mermaid>...</mermaid>
标记之间:
Here’s a diagram: <<mermaid> graph TD; A-->B; </mermaid>
可以在标记选项中设置任何参数。标记选项的优先级高于配置选项,因此您可以覆盖特定关系图的某些值,同时在配置中设置默认值。
标记也有一个排他选项caption
-图表图像的标记标题。
Diagram with a caption: <<mermaid caption="Deployment diagram" params="theme: dark"> </mermaid>
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'}
.