适用于Trac 1.4及更高版本的Graphviz插件
项目描述
描述
The graphviz wiki processor is a plugin for Trac that allows the the dynamic generation of diagrams by the various graphviz programs. The text of a wiki page can contain the source text for graphviz and the web browser will show the resulting image.
简单示例
一个简单的示例可能如下所示
#!graphviz digraph G {Hello->World->Graphviz->Rules}
在examples目录中还有几个额外的示例。可以通过examples/load_examples.py程序将它们加载到Trac安装中。加载后,导航到wiki/GraphvizExamples页面以访问示例。
使用说明
graphviz wiki处理器支持所有5个graphviz绘图程序:dot、neato、twopi、circo和fdp。默认情况下,使用dot程序生成图像。
可以使用以下方式调用不同的程序之一
#!graphviz #!graphviz.dot #!graphviz.neato #!graphviz.twopi #!graphviz.circo #!graphviz.fdp
支持的图像格式有:png(默认)、gif、jpg、svg和svgz。可以使用“/format”修饰符在hashbang中指定格式,如下所示
#!graphviz/svg #!graphviz.dot/png #!graphviz.circo/gif
平台特定要求
FreeBSD
在FreeBSD系统上,安装x11-fonts/urwfonts包将为graphviz正确生成图像提供所需的字体。
可选要求
为了允许使用 graphviz 生成的 PNG 图像进行抗锯齿处理,您需要在系统中安装 librsvg,这是一个位图转换器。可以从以下网址下载:http://librsvg.sourceforge.net/。注意,rsvg 在 Windows 上不可用。
通过源代码安装
从源代码安装 graphviz 插件是通过创建一个 Python egg 分发文件并将 .egg 文件复制到 Trac 插件目录来完成的。有关 Python eggs 的详细信息,请参阅:http://peak.telecommunity.com/DevCenter/PythonEggs。此外,需要 Easy Install 软件包来创建 Python eggs。有关使用和安装 Easy Install 的更多信息,请参阅:http://peak.telecommunity.com/DevCenter/EasyInstall。
从 http://trac-hacks.swapoff.org/download/graphvizplugin.zip 下载 graphviz 插件的源代码,或从 trac-hacks 子版本库中检出源代码:http://trac-hacks.swapoff.org/svn/graphvizplugin。
切换到 graphvizplugin/0.11 目录并运行
python setup.py bdist_egg
这将在 dist 目录中生成一个 python egg。将 egg 文件复制到 trac/plugins 目录,并按照下面的配置步骤操作。
通过 Egg 安装
待办事项
配置
通过源代码或通过 Python egg 安装 graphviz 插件后,在可以使用之前,需要对 conf/trac.ini 文件进行一些修改。
对于任何插件,如果您进行了全局安装(而不是简单地将其 .egg 文件放入 Trac 环境的插件文件夹中),首先需要启用它
[components] graphviz.* = enabled
应在 trac.ini 文件中添加一个新的名为 [graphviz] 的部分,包含以下字段
cache_dir - The directory that will be used to cache the generated images. That directory must exist, unless you keep the default 'gvcache' value, in which case the plugin is allowed to create the folder inside the Trac environment. cmd_path - Full path to the directory where the graphviz programs are located. If not specified, the default is /usr/bin on Linux, c:\Program Files\ATT\Graphviz\bin on Windows and /usr/local/bin on FreeBSD 6. out_format - Graph output format. Valid formats are: png, jpg, svg, svgz, gif. If not specified, the default is png. This setting can be overrided on a per-graph basis. processor - Graphviz default processor. Valid processors are: dot, neato, twopi, fdp, circo. If not specified, the default is dot. This setting can be overrided on a per-graph basis. GraphvizMacro will verify that the default processor is installed and will not work if it is missing. All other processors are optional. If any of the other processors are missing, a warning message will be sent to the trac log and GraphvizMacro will continue to work. png_antialias - If this entry exists in the configuration file, then PNG outputs will be antialiased. rsvg_path - Full path to the rsvg program (including the filename). The default is `<cmd_path>/rsvg`. default_* - These settings define the default graph, node and edge attributes. They must be written as: default_TYPE_ATTRIBUTE = VALUE where TYPE is one of graph, node, edge ATTRIBUTE is a valid graphviz attribute VALUE is the attribute value. eg: default_edge_fontname = "Andale Mono" default_graph_fontsize = 10 cache_manager - If this entry exists in the configuration file, then the cache management logic will be invoked and the cache_max_size, cache_min_size, cache_max_count and cache_min_count must be defined. cache_max_size - The maximum size in bytes that the cache should consume. This is the high watermark for disk space used. cache_min_size - When cleaning out the cache, remove files until this size in bytes is used by the cache. This is the low watermark for disk space used. cache_max_count - The maximum number of files that the cache should contain. This is the high watermark for the directory entry count.
cache_dir 目录必须存在,并且 trac 服务器必须具有读写权限。
缓存管理器是尝试控制缓存目录的尝试。这是实验性代码,可能带来的问题比解决的问题更多。只有在需要生成新的 graphviz 图像时才会调用缓存管理器。如果可以从缓存中加载图像,则不需要运行缓存管理器。这应该最大限度地减少对 trac 服务器 I/O 性能的影响。当缓存管理器确定应该清理缓存时,它将根据文件访问时间删除文件。最不常访问的文件将首先被删除。
配置示例
以下是一个示例 graphviz 部分
[graphviz] cache_dir = /tmp/trac/htdocs/graphviz png_antialias = true default_graph_fontname = "Andale Mono" default_graph_fontsize = 10
以下是一个示例 graphviz 部分,它激活了缓存管理器
[graphviz] cache_dir = /tmp/trac/htdocs/graphviz png_antialias = true default_graph_fontname = "Andale Mono" default_graph_fontsize = 10 cache_manager = yes cache_max_size = 10000000 cache_min_size = 5000000 cache_max_count = 2000 cache_min_count = 1500
由于在 graphviz 部分中有一个名为 cache_manager 的条目,因此缓存管理器已被开启。值无关紧要。要关闭缓存管理器,只需注释掉 cache_manager 条目。
当缓存目录中所有文件的总大小超过 10,000,000 字节或文件数量超过 2,000 时,将删除文件,直到大小小于 5,000,000 字节且文件数量小于 1,500。
以下是相同示例,但适用于 Windows 系统
[graphviz] cache_dir = C:\projects\plugins\env\trac\htdocs\graphviz cache_manager = yes cache_max_size = 10000000 cache_min_size = 5000000 cache_max_count = 2000 cache_min_count = 1500
请注意,png_antialias、rsvg_path、default_graph_fontname 和 default_graph_fontsize 没有定义。这是因为 rsvg 在 Windows 上不可用,并且这些选项没有被使用。
贡献者
我想对以下人员表示感谢
Kilian Cavalotti 为
编写代码以允许在系统范围和每个图表中指定输出格式。
在代码中扩展 Trac wiki 链接以在 Graphviz 图表中使用。
Alec Thomas 为创建 Trac Hacks (http://trac-hacks.swapoff.org) 并提供 Graphviz 模块的托管服务。
感谢Emmanuel Blot迅速解决0.9 - 0.10版本相关bug修复问题;-)
$Id: README.rst 17774 2020-05-28 16:25:13Z rjollos $
项目详情
TracGraphviz-1.4.0.3.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | afedb0d57ac91ba956278bba8c5bdfc8727db9333aa3f5a15626105ef260ac25 |
|
MD5 | ac62cb72e1bace48292dd4f3ed90eec6 |
|
BLAKE2b-256 | e7df3157a9545ad723f9353b67c460c2160466d35f63e76fe4e6640d69df161f |
TracGraphviz-1.4.0.3-py2.py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 026048bb903de5f7ed48ad5952c9d365226938acc93104e99d0a52b4c4509d13 |
|
MD5 | c44794cb8c39a508db7930741a989d7e |
|
BLAKE2b-256 | 228d5a7c8fbe54db0afb41c5b47dccddd9c2eb4767d40d288b67bbe92d4005a5 |