]> gitweb.factorcode.org Git - factor.git/blob - extra/graphviz/render/render-docs.factor
*-docs: replace double spaces with single spaces
[factor.git] / extra / graphviz / render / render-docs.factor
1 ! Copyright (C) 2012 Alex Vondrak.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: graphviz help.markup help.syntax images.viewer
4 io.encodings.8-bit.latin1 io.encodings.utf8 io.launcher kernel
5 strings ;
6 IN: graphviz.render
7
8 { cannot-find-graphviz-installation default-graphviz-program ?default-graphviz-program } related-words
9 { unsupported-encoding graph-encoding } related-words
10 { unsupported-preview-format preview-format } related-words
11 { graphviz graphviz* } related-words
12 { preview preview-window } related-words
13 { circo dot fdp neato osage sfdp twopi } related-words
14 { bmp canon dot-file xdot cmap eps fig gd gd2 gif ico imap cmapx imap_np cmapx_np ismap jpg jpeg jpe pdf plain plain-ext png ps ps2 svg svgz tif tiff vml vmlz vrml wbmp webp } related-words
15
16 HELP: cannot-find-graphviz-installation
17 { $error-description "Thrown by " { $link ?default-graphviz-program } " if a Graphviz installation cannot be found." } ;
18
19 HELP: unsupported-encoding
20 { $values
21     { "graph-encoding" "a character encoding" }
22 }
23 { $error-description "Thrown by " { $links graphviz graphviz* preview preview-window } ", and related words if " { $link graph-encoding } " has a value other than " { $link utf8 } " or " { $link latin1 } "." } ;
24
25 HELP: unsupported-preview-format
26 { $values
27     { "preview-format" string }
28 }
29 { $error-description "Thrown by " { $link preview } " or " { $link preview-window } " if " { $link preview-format } " has a value that's not supported by " { $vocab-link "images.loader" } "." } ;
30
31 HELP: ?default-graphviz-program
32 { $values
33         { "path" "a pathname string" }
34 }
35 { $description "Searches your computer for the path to a Graphviz executable." }
36 { $errors "Throws an error if a Graphviz installation cannot be found." } ;
37
38 HELP: default-graphviz-program
39 { $values
40         { "path/f" { $maybe "a pathname string" } }
41 }
42 { $description "Searches your computer for the path to a Graphviz executable. If one cannot be found, returns " { $link f } "."
43 $nl
44 "On a Unix machine, this involves looking for " { $snippet "circo" } ", " { $snippet "dot" } ", " { $snippet "fdp" } ", " { $snippet "neato" } ", " { $snippet "osage" } ", " { $snippet "sfdp" } ", or " { $snippet "twopi" } " somewhere in your " { $snippet "PATH" } "."
45 $nl
46 "On Windows, if you have Graphviz installed into a folder whose name begins with " { $snippet "Graphviz" } " in either " { $snippet "Program Files" } " or " { $snippet "Program Files(x86)" } ", that folder will be searched for an executable named " { $snippet "circo.exe" } ", " { $snippet "dot.exe" } ", " { $snippet "fdp.exe" } ", " { $snippet "neato.exe" } ", " { $snippet "osage.exe" } ", " { $snippet "sfdp.exe" } ", or " { $snippet "twopi.exe" } "."
47 } ;
48
49 HELP: default-layout
50 { $var-description "A " { $link string } " representing the layout engine implicitly used by " { $links graphviz* preview preview-window } ", and related words." }
51 { $notes "Must be an image format supported by " { $vocab-link "images.loader" } "." } ;
52
53 HELP: graph-encoding
54 { $var-description "The character encoding used when writing " { $instance graph } " to a DOT file." }
55 { $notes "To match Graphviz's valid values for a graph's " { $snippet "charset" } " attribute (see " { $url "http://graphviz.org/content/attrs#dcharset" } "), this global variable must either be " { $link utf8 } " or " { $link latin1 } ". If it does not match your graph's " { $snippet "charset" } ", your output may be incorrect." } ;
56
57 HELP: preview-format
58 { $var-description "A " { $link string } " representing the output format implicitly used by " { $link preview } " and " { $link preview-window } "." } ;
59
60 HELP: graphviz
61 { $values
62     { "graph" graph } { "path" "a pathname string" } { "format" string } { "layout" string }
63 }
64 { $description "Translates " { $snippet "graph" } " into DOT code and invokes Graphviz on the result."
65 $nl
66 { $snippet "path" } " is the location where you want to save your output, " { $emphasis "without" } " a file extension (Graphviz will automatically add one based on " { $snippet "format" } ")."
67 $nl
68 { $snippet "format" } " is the format of your output (e.g., " { $snippet "\"png\"" } ")."
69 $nl
70 { $snippet "layout" } " is the layout engine to use (e.g., " { $snippet "\"dot\"" } ")."
71 $nl
72 "Essentially, you can think of it as equivalent to running the Graphviz command \"" { $strong "dot" } " " { $snippet "path" } " " { $strong "-O" } " " { $strong "-T" } { $snippet "format" } " " { $strong "-K" } { $snippet "layout" } "\". See " { $url "http://graphviz.org/content/command-line-invocation" } "."
73 }
74 { $errors
75 "If the Graphviz process encounters an error, its output will be captured and thrown as " { $instance output-process-error } " by Factor."
76 $nl
77 "Throws " { $instance unsupported-encoding } " error if " { $link graph-encoding } " isn't one of " { $link utf8 } " or " { $link latin1 } "."
78 }
79 { $examples "To render a " { $link graph } " " { $snippet "G" } " using circo and save the output to a PNG file, you could write" { $code "G \"foo\" \"png\" \"circo\" graphviz" } "(assuming circo and PNG are supported by your Graphviz installation). This will save the output to the file " { $snippet "foo.png" } "." } ;
80
81 HELP: graphviz*
82 { $values
83     { "graph" graph } { "path" "a pathname string" } { "format" string }
84 }
85 { $description "Invokes the " { $link graphviz } " word using the value of " { $link default-layout } " as the layout engine. That is, the following two lines are equivalent:"
86 { $code "graph path format default-layout get-global graphviz" "graph path format graphviz*" }
87 }
88 { $examples "To render a " { $link graph } " " { $snippet "G" } " when you don't particularly care about the layout engine but want to save the output to a PNG file, you could write" { $code "G \"foo\" \"png\" graphviz*" } "(assuming that " { $link default-layout } " and PNG are supported by your Graphviz installation). This will save the output to the file " { $snippet "foo.png" } "." } ;
89
90 HELP: preview
91 { $values
92     { "graph" graph }
93 }
94 { $description "Renders " { $snippet "graph" } " to a temporary file using " { $link preview-format } " and " { $link default-layout } ". Then, using " { $link image. } ", displays the image in the UI listener before deleting the temporary file." }
95 { $errors
96 "Throws " { $instance unsupported-preview-format } " error if " { $link preview-format } " is not supported by " { $vocab-link "images.loader" } "."
97 $nl
98 "If the Graphviz process encounters an error, its output will be captured and thrown as " { $instance output-process-error } " by Factor."
99 $nl
100 "Throws " { $instance unsupported-encoding } " error if " { $link graph-encoding } " isn't one of " { $link utf8 } " or " { $link latin1 } "."
101 } ;
102
103 HELP: preview-window
104 { $values
105     { "graph" graph }
106 }
107 { $description "Renders " { $snippet "graph" } " to a temporary file using " { $link preview-format } " and " { $link default-layout } ". Then, using " { $link image-window } ", opens a new window displaying the image before deleting the temporary file." }
108 { $errors
109 "Throws " { $instance unsupported-preview-format } " error if " { $link preview-format } " is not supported by " { $vocab-link "images.loader" } "."
110 $nl
111 "If the Graphviz process encounters an error, its output will be captured and thrown as " { $instance output-process-error } " by Factor."
112 $nl
113 "Throws " { $instance unsupported-encoding } " error if " { $link graph-encoding } " isn't one of " { $link utf8 } " or " { $link latin1 } "."
114 } ;
115
116 !
117
118 HELP: circo
119 { $values
120     { "graph" graph } { "path" "a pathname string" } { "format" string }
121 }
122 { $description "Invokes " { $link graphviz } " with " { $snippet "\"circo\"" } " supplied as the layout engine. That is, the following two lines are equivalent:" { $code "graph path format \"circo\" graphviz" "graph path format circo" } } ;
123
124 HELP: dot
125 { $values
126     { "graph" graph } { "path" "a pathname string" } { "format" string }
127 }
128 { $description "Invokes " { $link graphviz } " with " { $snippet "\"dot\"" } " supplied as the layout engine. That is, the following two lines are equivalent:" { $code "graph path format \"dot\" graphviz" "graph path format dot" } } ;
129
130 HELP: fdp
131 { $values
132     { "graph" graph } { "path" "a pathname string" } { "format" string }
133 }
134 { $description "Invokes " { $link graphviz } " with " { $snippet "\"fdp\"" } " supplied as the layout engine. That is, the following two lines are equivalent:" { $code "graph path format \"fdp\" graphviz" "graph path format fdp" } } ;
135
136 HELP: neato
137 { $values
138     { "graph" graph } { "path" "a pathname string" } { "format" string }
139 }
140 { $description "Invokes " { $link graphviz } " with " { $snippet "\"neato\"" } " supplied as the layout engine. That is, the following two lines are equivalent:" { $code "graph path format \"neato\" graphviz" "graph path format neato" } } ;
141
142 HELP: osage
143 { $values
144     { "graph" graph } { "path" "a pathname string" } { "format" string }
145 }
146 { $description "Invokes " { $link graphviz } " with " { $snippet "\"osage\"" } " supplied as the layout engine. That is, the following two lines are equivalent:" { $code "graph path format \"osage\" graphviz" "graph path format osage" } } ;
147
148 HELP: sfdp
149 { $values
150     { "graph" graph } { "path" "a pathname string" } { "format" string }
151 }
152 { $description "Invokes " { $link graphviz } " with " { $snippet "\"sfdp\"" } " supplied as the layout engine. That is, the following two lines are equivalent:" { $code "graph path format \"sfdp\" graphviz" "graph path format sfdp" } } ;
153
154 HELP: twopi
155 { $values
156     { "graph" graph } { "path" "a pathname string" } { "format" string }
157 }
158 { $description "Invokes " { $link graphviz } " with " { $snippet "\"twopi\"" } " supplied as the layout engine. That is, the following two lines are equivalent:" { $code "graph path format \"twopi\" graphviz" "graph path format twopi" } } ;
159
160 !
161
162 HELP: bmp
163 { $values
164     { "graph" graph } { "path" "a pathname string" }
165 }
166 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"bmp\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"bmp\" graphviz*" "graph path bmp" } } ;
167
168 HELP: canon
169 { $values
170     { "graph" graph } { "path" "a pathname string" }
171 }
172 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"canon\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"canon\" graphviz*" "graph path canon" } } ;
173
174 HELP: cmap
175 { $values
176     { "graph" graph } { "path" "a pathname string" }
177 }
178 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"cmap\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"cmap\" graphviz*" "graph path cmap" } } ;
179
180 HELP: cmapx
181 { $values
182     { "graph" graph } { "path" "a pathname string" }
183 }
184 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"cmapx\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"cmapx\" graphviz*" "graph path cmapx" } } ;
185
186 HELP: cmapx_np
187 { $values
188     { "graph" graph } { "path" "a pathname string" }
189 }
190 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"cmapx_np\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"cmapx_np\" graphviz*" "graph path cmapx_np" } } ;
191
192 HELP: dot-file
193 { $values
194     { "graph" graph } { "path" "a pathname string" }
195 }
196 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"dot\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"dot\" graphviz*" "graph path dot-file" } } ;
197
198 HELP: eps
199 { $values
200     { "graph" graph } { "path" "a pathname string" }
201 }
202 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"eps\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"eps\" graphviz*" "graph path eps" } } ;
203
204 HELP: fig
205 { $values
206     { "graph" graph } { "path" "a pathname string" }
207 }
208 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"fig\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"fig\" graphviz*" "graph path fig" } } ;
209
210 HELP: gd
211 { $values
212     { "graph" graph } { "path" "a pathname string" }
213 }
214 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"gd\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"gd\" graphviz*" "graph path gd" } } ;
215
216 HELP: gd2
217 { $values
218     { "graph" graph } { "path" "a pathname string" }
219 }
220 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"gd2\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"gd2\" graphviz*" "graph path gd2" } } ;
221
222 HELP: gif
223 { $values
224     { "graph" graph } { "path" "a pathname string" }
225 }
226 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"gif\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"gif\" graphviz*" "graph path gif" } } ;
227
228 HELP: ico
229 { $values
230     { "graph" graph } { "path" "a pathname string" }
231 }
232 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"ico\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"ico\" graphviz*" "graph path ico" } } ;
233
234 HELP: imap
235 { $values
236     { "graph" graph } { "path" "a pathname string" }
237 }
238 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"imap\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"imap\" graphviz*" "graph path imap" } } ;
239
240 HELP: imap_np
241 { $values
242     { "graph" graph } { "path" "a pathname string" }
243 }
244 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"imap_np\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"imap_np\" graphviz*" "graph path imap_np" } } ;
245
246 HELP: ismap
247 { $values
248     { "graph" graph } { "path" "a pathname string" }
249 }
250 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"ismap\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"ismap\" graphviz*" "graph path ismap" } } ;
251
252 HELP: jpe
253 { $values
254     { "graph" graph } { "path" "a pathname string" }
255 }
256 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"jpe\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"jpe\" graphviz*" "graph path jpe" } } ;
257
258 HELP: jpeg
259 { $values
260     { "graph" graph } { "path" "a pathname string" }
261 }
262 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"jpeg\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"jpeg\" graphviz*" "graph path jpeg" } } ;
263
264 HELP: jpg
265 { $values
266     { "graph" graph } { "path" "a pathname string" }
267 }
268 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"jpg\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"jpg\" graphviz*" "graph path jpg" } } ;
269
270 HELP: pdf
271 { $values
272     { "graph" graph } { "path" "a pathname string" }
273 }
274 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"pdf\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"pdf\" graphviz*" "graph path pdf" } } ;
275
276 HELP: plain
277 { $values
278     { "graph" graph } { "path" "a pathname string" }
279 }
280 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"plain\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"plain\" graphviz*" "graph path plain" } } ;
281
282 HELP: plain-ext
283 { $values
284     { "graph" graph } { "path" "a pathname string" }
285 }
286 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"plain-ext\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"plain-ext\" graphviz*" "graph path plain-ext" } } ;
287
288 HELP: png
289 { $values
290     { "graph" graph } { "path" "a pathname string" }
291 }
292 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"png\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"png\" graphviz*" "graph path png" } } ;
293
294 HELP: ps
295 { $values
296     { "graph" graph } { "path" "a pathname string" }
297 }
298 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"ps\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"ps\" graphviz*" "graph path ps" } } ;
299
300 HELP: ps2
301 { $values
302     { "graph" graph } { "path" "a pathname string" }
303 }
304 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"ps2\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"ps2\" graphviz*" "graph path ps2" } } ;
305
306 HELP: svg
307 { $values
308     { "graph" graph } { "path" "a pathname string" }
309 }
310 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"svg\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"svg\" graphviz*" "graph path svg" } } ;
311
312 HELP: svgz
313 { $values
314     { "graph" graph } { "path" "a pathname string" }
315 }
316 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"svgz\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"svgz\" graphviz*" "graph path svgz" } } ;
317
318 HELP: tif
319 { $values
320     { "graph" graph } { "path" "a pathname string" }
321 }
322 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"tif\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"tif\" graphviz*" "graph path tif" } } ;
323
324 HELP: tiff
325 { $values
326     { "graph" graph } { "path" "a pathname string" }
327 }
328 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"tiff\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"tiff\" graphviz*" "graph path tiff" } } ;
329
330 HELP: vml
331 { $values
332     { "graph" graph } { "path" "a pathname string" }
333 }
334 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"vml\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"vml\" graphviz*" "graph path vml" } } ;
335
336 HELP: vmlz
337 { $values
338     { "graph" graph } { "path" "a pathname string" }
339 }
340 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"vmlz\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"vmlz\" graphviz*" "graph path vmlz" } } ;
341
342 HELP: vrml
343 { $values
344     { "graph" graph } { "path" "a pathname string" }
345 }
346 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"vrml\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"vrml\" graphviz*" "graph path vrml" } } ;
347
348 HELP: wbmp
349 { $values
350     { "graph" graph } { "path" "a pathname string" }
351 }
352 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"wbmp\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"wbmp\" graphviz*" "graph path wbmp" } } ;
353
354 HELP: webp
355 { $values
356     { "graph" graph } { "path" "a pathname string" }
357 }
358 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"webp\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"webp\" graphviz*" "graph path webp" } } ;
359
360 HELP: xdot
361 { $values
362     { "graph" graph } { "path" "a pathname string" }
363 }
364 { $description "Invokes " { $link graphviz* } " with " { $snippet "\"xdot\"" } " supplied as the output format. That is, the following two lines are equivalent:" { $code "graph path \"xdot\" graphviz*" "graph path xdot" } } ;
365
366 ARTICLE: { "graphviz.render" "layouts" } "Rendering graphs by layout engine"
367 "For each \"standard\" layout command listed in " { $url "http://graphviz.org/Documentation.php" } ", the " { $vocab-link "graphviz.render" } " vocabulary defines a corresponding word that calls " { $link graphviz } " with that layout engine already supplied as an argument. For instance, instead of writing" { $code "graph path format \"dot\" graphviz" } "you can simply write" { $code "graph path format dot" }
368 $nl
369 "The following words are defined:"
370 { $subsections circo dot fdp neato osage sfdp twopi } ;
371
372 ARTICLE: { "graphviz.render" "formats" } "Rendering graphs by output format"
373 "For each output format listed in " { $url "http://graphviz.org/content/output-formats" } ", the " { $vocab-link "graphviz.render" } " vocabulary defines a corresponding word that calls " { $link graphviz* } " with that format already supplied as an argument. For instance, instead of writing" { $code "graph path \"png\" graphviz*" } "you can simply write" { $code "graph path png" }
374 $nl
375 "In the case of the " { $snippet "dot" } " output format (which already has the " { $link dot } " shortcut defined for the layout engine), the shortcut function is named " { $link dot-file } "."
376 $nl
377 "The following words are defined:"
378 { $subsections bmp canon dot-file xdot cmap eps fig gd gd2 gif ico imap cmapx imap_np cmapx_np ismap jpg jpeg jpe pdf plain plain-ext png ps ps2 svg svgz tif tiff vml vmlz vrml wbmp webp } ;
379
380 ARTICLE: "graphviz.render" "Rendering Graphviz output"
381 "The " { $vocab-link "graphviz.render" } " vocabulary provides words for converting " { $link graph } " objects into equivalent Graphviz output. This is done by using the " { $vocab-link "graphviz.dot" } " vocabulary to convert the Factor objects into equivalent DOT code, then invoking Graphviz upon the result."
382 $nl
383 "The most general words in this vocabulary will have you manually specify the desired layout engine and/or output format, along with a file to which Graphviz should save its output:"
384 { $subsections
385     graphviz
386     graphviz*
387 }
388
389 "If the graph is small enough, it may be convenient to see an image of it using Factor's UI listener:"
390 { $subsections
391     preview
392     preview-window
393 }
394
395 "A few global variables are used to control the above words:"
396 { $subsections
397     default-layout
398     graph-encoding
399     preview-format
400 }
401
402 "Shortcut words are also defined to save on extra typing:"
403 { $subsections
404     { "graphviz.render" "layouts" }
405     { "graphviz.render" "formats" }
406 }
407 ;
408
409 ABOUT: "graphviz.render"