| 1 |
Trac Graphviz Wiki Processor |
|---|
| 2 |
---------------------------- |
|---|
| 3 |
|
|---|
| 4 |
Description |
|---|
| 5 |
=========== |
|---|
| 6 |
|
|---|
| 7 |
The graphviz wiki processor is a plugin for Trac that allows the the |
|---|
| 8 |
dynamic generation of diagrams by the various graphviz programs. The |
|---|
| 9 |
text of a wiki page can contain the source text for graphviz and the |
|---|
| 10 |
web browser will show the resulting image. |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
Simple Example |
|---|
| 14 |
++++++++++++++ |
|---|
| 15 |
|
|---|
| 16 |
A simple example would be: |
|---|
| 17 |
|
|---|
| 18 |
{{{ |
|---|
| 19 |
#!graphviz |
|---|
| 20 |
digraph G {Hello->World->Graphviz->Rules} |
|---|
| 21 |
}}} |
|---|
| 22 |
|
|---|
| 23 |
There are also several additional examples available in the examples |
|---|
| 24 |
directory. They can be loaded into a Trac installation by the |
|---|
| 25 |
examples/load_examples.py program. Once loaded, navigate to the |
|---|
| 26 |
wiki/GraphvizExamples page to access the examples. |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
Usage Details |
|---|
| 30 |
+++++++++++++ |
|---|
| 31 |
|
|---|
| 32 |
The graphviz wiki processor supports all 5 graphviz drawing programs: |
|---|
| 33 |
dot, neato, twopi, circo and fdp. By default, the dot program is used |
|---|
| 34 |
to generate the images. |
|---|
| 35 |
|
|---|
| 36 |
The different programs can be invoked using one of these: |
|---|
| 37 |
|
|---|
| 38 |
#!graphviz |
|---|
| 39 |
#!graphviz.dot |
|---|
| 40 |
#!graphviz.neato |
|---|
| 41 |
#!graphviz.twopi |
|---|
| 42 |
#!graphviz.circo |
|---|
| 43 |
#!graphviz.fdp |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
The supported image formats are: png (default), gif, jpg, svg and svgz. |
|---|
| 47 |
The format can be specified using a "/format" modifier, in the hashbang, |
|---|
| 48 |
as shown below: |
|---|
| 49 |
|
|---|
| 50 |
#!graphviz/svg |
|---|
| 51 |
#!graphviz.dot/png |
|---|
| 52 |
#!graphviz.circo/gif |
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
Platform Specific Requirements |
|---|
| 56 |
============================== |
|---|
| 57 |
|
|---|
| 58 |
FreeBSD |
|---|
| 59 |
+++++++ |
|---|
| 60 |
|
|---|
| 61 |
On FreeBSD systems, installing the x11-fonts/urwfonts package will |
|---|
| 62 |
provide the fonts needed for graphviz to correctly generate images. |
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
Optional requirements |
|---|
| 66 |
===================== |
|---|
| 67 |
|
|---|
| 68 |
To allow antialiasing of PNG images produced by graphviz, you need to |
|---|
| 69 |
have rsvg, the librsvg rasterizer, installed on your system. It can be |
|---|
| 70 |
downloaded from <http://librsvg.sourceforge.net/>. Note that rsvg is |
|---|
| 71 |
not available for Windows. |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
Installation via Source |
|---|
| 75 |
======================= |
|---|
| 76 |
|
|---|
| 77 |
The installation of the graphviz plugin from source is done by |
|---|
| 78 |
creating a Python egg distribution file and copying the .egg file to |
|---|
| 79 |
the Trac plugins directory. Detailed information on Python eggs can be |
|---|
| 80 |
found at: http://peak.telecommunity.com/DevCenter/PythonEggs. In |
|---|
| 81 |
addition, the Easy Install package is required to create Python |
|---|
| 82 |
eggs. See http://peak.telecommunity.com/DevCenter/EasyInstall for more |
|---|
| 83 |
information on using and installing Easy Install. |
|---|
| 84 |
|
|---|
| 85 |
Download the source code for the graphviz plugin from |
|---|
| 86 |
http://trac-hacks.swapoff.org/download/graphvizplugin.zip or checkout |
|---|
| 87 |
the source from the trac hacks subversion repository at: |
|---|
| 88 |
http://trac-hacks.swapoff.org/svn/graphvizplugin. |
|---|
| 89 |
|
|---|
| 90 |
Change to the graphvizplugin/0.9 directory and run: |
|---|
| 91 |
|
|---|
| 92 |
python setup.py bdist_egg |
|---|
| 93 |
|
|---|
| 94 |
This will generate a python egg in the dist directory. Copy the egg |
|---|
| 95 |
file into the trac/plugins directory and follow the Configuration |
|---|
| 96 |
steps outlined below. |
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
Installation via Egg |
|---|
| 100 |
==================== |
|---|
| 101 |
|
|---|
| 102 |
todo |
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
Configuration |
|---|
| 106 |
============= |
|---|
| 107 |
|
|---|
| 108 |
Once the graphviz plugin has been installed either via source or via a |
|---|
| 109 |
python egg, some configuration is needed before it can be used. |
|---|
| 110 |
|
|---|
| 111 |
A new section called graphviz should be added to the conf/trac.ini |
|---|
| 112 |
file with these fields: |
|---|
| 113 |
|
|---|
| 114 |
cache_dir - The directory that will be used to cache the |
|---|
| 115 |
generated images. |
|---|
| 116 |
|
|---|
| 117 |
cmd_path - Full path to the directory where the graphviz |
|---|
| 118 |
programs are located. If not specified, the |
|---|
| 119 |
default is /usr/bin on Linux, c:\Program |
|---|
| 120 |
Files\ATT\Graphviz\bin on Windows and |
|---|
| 121 |
/usr/local/bin on FreeBSD 6. |
|---|
| 122 |
|
|---|
| 123 |
out_format - Graph output format. Valid formats are: png, jpg, |
|---|
| 124 |
svg, svgz, gif. If not specified, the default is |
|---|
| 125 |
png. This setting can be overrided on a per-graph |
|---|
| 126 |
basis. |
|---|
| 127 |
|
|---|
| 128 |
processor - Graphviz default processor. Valid processors |
|---|
| 129 |
are: dot, neato, twopi, fdp, circo. If not |
|---|
| 130 |
specified, the default is dot. This setting can |
|---|
| 131 |
be overrided on a per-graph basis. |
|---|
| 132 |
|
|---|
| 133 |
GraphvizMacro will verify that the default |
|---|
| 134 |
processor is installed and will not work if it |
|---|
| 135 |
is missing. All other processors are optional. |
|---|
| 136 |
If any of the other processors are missing, a |
|---|
| 137 |
warning message will be sent to the trac log and |
|---|
| 138 |
GraphvizMacro will continue to work. |
|---|
| 139 |
|
|---|
| 140 |
png_antialias - If this entry exists in the configuration file, |
|---|
| 141 |
then PNG outputs will be antialiased. |
|---|
| 142 |
|
|---|
| 143 |
rsvg_path - Full path to where the rsvg binary can be found. |
|---|
| 144 |
The default is cmd_path + rsvg. |
|---|
| 145 |
|
|---|
| 146 |
default_* - These settings define the default graph, node and |
|---|
| 147 |
edge attributes. They must be written as : |
|---|
| 148 |
default_TYPE_ATTRIBUTE = VALUE |
|---|
| 149 |
where TYPE is one of graph, node, edge |
|---|
| 150 |
ATTRIBUTE is a valid graphviz attribute |
|---|
| 151 |
VALUE is the attribute value. |
|---|
| 152 |
eg: default_edge_fontname = "Andale Mono" |
|---|
| 153 |
default_graph_fontsize = 10 |
|---|
| 154 |
|
|---|
| 155 |
cache_manager - If this entry exists in the configuration file, |
|---|
| 156 |
then the cache management logic will be invoked |
|---|
| 157 |
and the cache_max_size, cache_min_size, |
|---|
| 158 |
cache_max_count and cache_min_count must be |
|---|
| 159 |
defined. |
|---|
| 160 |
|
|---|
| 161 |
cache_max_size - The maximum size in bytes that the cache should |
|---|
| 162 |
consume. This is the high watermark for disk space |
|---|
| 163 |
used. |
|---|
| 164 |
|
|---|
| 165 |
cache_min_size - When cleaning out the cache, remove files until |
|---|
| 166 |
this size in bytes is used by the cache. This is |
|---|
| 167 |
the low watermark for disk space used. |
|---|
| 168 |
|
|---|
| 169 |
cache_max_count - The maximum number of files that the cache should |
|---|
| 170 |
contain. This is the high watermark for the |
|---|
| 171 |
directory entry count. |
|---|
| 172 |
|
|---|
| 173 |
The cache_dir directory must exist and the trac server must have read |
|---|
| 174 |
and write access. |
|---|
| 175 |
|
|---|
| 176 |
The cache manager is an attempt at keeping the cache directory under |
|---|
| 177 |
control. This is experimental code that may cause more problems than |
|---|
| 178 |
it fixes. The cache manager will be invoked only if a new graphviz |
|---|
| 179 |
image is to be produced. If the image can be loaded from the cache, |
|---|
| 180 |
then the cache manager shouldn't need to run. This should minimize the |
|---|
| 181 |
I/O performance impact on the trac server. When the cache manager |
|---|
| 182 |
determines that it should clean up the cache, it will delete files |
|---|
| 183 |
based on the file access time. The files that were least accessed will |
|---|
| 184 |
be deleted first. |
|---|
| 185 |
|
|---|
| 186 |
|
|---|
| 187 |
Configuration Example |
|---|
| 188 |
+++++++++++++++++++++ |
|---|
| 189 |
|
|---|
| 190 |
Here is a sample graphviz section: |
|---|
| 191 |
|
|---|
| 192 |
[graphviz] |
|---|
| 193 |
cache_dir = /tmp/trac/htdocs/graphviz |
|---|
| 194 |
png_antialias = true |
|---|
| 195 |
default_graph_fontname = "Andale Mono" |
|---|
| 196 |
default_graph_fontsize = 10 |
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 |
Here is a sample graphviz section that activates the cache manager: |
|---|
| 200 |
|
|---|
| 201 |
[graphviz] |
|---|
| 202 |
cache_dir = /tmp/trac/htdocs/graphviz |
|---|
| 203 |
png_antialias = true |
|---|
| 204 |
default_graph_fontname = "Andale Mono" |
|---|
| 205 |
default_graph_fontsize = 10 |
|---|
| 206 |
cache_manager = yes |
|---|
| 207 |
cache_max_size = 10000000 |
|---|
| 208 |
cache_min_size = 5000000 |
|---|
| 209 |
cache_max_count = 2000 |
|---|
| 210 |
cache_min_count = 1500 |
|---|
| 211 |
|
|---|
| 212 |
The cache manager is turned on since there is an entry in the graphviz |
|---|
| 213 |
section called cache_manager. The value doesn't matter. To turn off |
|---|
| 214 |
the cache manager, simply comment out the cache_manager entry. |
|---|
| 215 |
|
|---|
| 216 |
When the size of all the files in the cache directory exceeds |
|---|
| 217 |
10,000,000 bytes or the number of files in the cache directory exceeds |
|---|
| 218 |
2,000, then files are deleted until the size is less than 5,000,000 |
|---|
| 219 |
bytes and the number of files is less than 1,500. |
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 |
Here's the same example but for Windows systems: |
|---|
| 223 |
|
|---|
| 224 |
[graphviz] |
|---|
| 225 |
cache_dir = C:\projects\plugins\env\trac\htdocs\graphviz |
|---|
| 226 |
cache_manager = yes |
|---|
| 227 |
cache_max_size = 10000000 |
|---|
| 228 |
cache_min_size = 5000000 |
|---|
| 229 |
cache_max_count = 2000 |
|---|
| 230 |
cache_min_count = 1500 |
|---|
| 231 |
|
|---|
| 232 |
Notice that the png_antialias, rsvg_path, default_graph_fontname and |
|---|
| 233 |
default_graph_fontsize are not defined. This is because rsvg is not |
|---|
| 234 |
available on Windows and these options are not used. |
|---|
| 235 |
|
|---|
| 236 |
|
|---|
| 237 |
Contributors |
|---|
| 238 |
============ |
|---|
| 239 |
|
|---|
| 240 |
I'd like to extend my thanks to following people: |
|---|
| 241 |
|
|---|
| 242 |
* Kilian Cavalotti for |
|---|
| 243 |
|
|---|
| 244 |
* the code to allow the output format to be specified system wide and |
|---|
| 245 |
per diagram. |
|---|
| 246 |
|
|---|
| 247 |
* work on the code to expand Trac wiki links within Graphviz |
|---|
| 248 |
diagrams. |
|---|
| 249 |
|
|---|
| 250 |
* Alec Thomas for creating Trac Hacks (http://trac-hacks.swapoff.org) |
|---|
| 251 |
and providing hosting for the Graphviz module. |
|---|
| 252 |
|
|---|
| 253 |
* Emmanuel Blot for the swift kick in the butt to get the 0.9 - 0.10 |
|---|
| 254 |
releated bug fixes resolved ;-) |
|---|
| 255 |
|
|---|
| 256 |
|
|---|
| 257 |
$Id$ |
|---|