Last Modified
Sun Oct 03 16:18:27 +0800 2010
Requires

Description

wdot.rb - Workflow / Flowchart extensions to grahpviz’s dot language.

License: GPL v2 or (at your option) any later version. See www.fsf.org/licensing .

Copyright (C) 2008-2010, Loh Siu Yin (siuyin@beyondbroadcast.com)

Graphviz’s dot language ( www.graphviz.org ) is a very flexible language that can generate graph images (.png, .svg etc) from a text file. However for creating workflow diagrams dot is very repetitious and rather verbose. In the spirit of “Don’t Repeat Yourself”, I wrote wdot.rb to eliminate most of the repetitious effort while still retaining the full flexibility of dot when I need it.

wdot.rb allows you to quickly create workflow diagrams / flowcharts easily from text files. As text files these can be updated with any text editor resulting in easily updateable diagrams.

Usage

wdot.rb < | dot -T -o

 eg. wdot.rb < my_diagram.wdot | dot -Tpng -o my_diagram.png

Examples

 # my_diagram.wdot
 :head  {
 _start
 _end
 proc1
 _start->proc1->_end
 }
 produces: 


 # my_diagram.wdot - with title and LR orientation
 :head  "My Diagram", LR {
 _start
 _end
 proc1
 _start->proc1->_end
 }
 produces: 


 # my_diagram.wdot - with title, LR orientation, no arrows
 :head  "My Diagram", LR {
 _start
 _end
 proc1
 proc2
 _start->proc1
 proc1--proc2
 proc2->_end
 }
 produces: 


 # my_diagram.wdot - with title, LR orientation, back arrow
 :head  "My Diagram", LR {
 _start
 _end
 proc1
 proc2
 _start->proc1
 proc1<-proc2
 proc2->_end
 }
 produces: 


 # my_diagram.wdot - with title, LR orientation, bi-directional arrow
 :head  "My Diagram", LR {
 _start
 _end
 proc1
 proc2
 _start->proc1
 proc1<->proc2
 proc2->_end
 }
 produces: 


 # my_diagram.wdot - node descriptions
 :head  "My Diagram", LR {
 _start "Start here."
 _end "All done."
 proc1 "Complex\nprocessing\nhere."
 _start->proc1->_end
 }
 produces: 


 # my_diagram.wdot - edge descriptions
 :head  "My Diagram", LR {
 _start "Start"
 _end "Done"
 proc1 "Complex\nprocessing\nhere."
 _start->proc1 "begin"
 proc1->_end "finish up"
 }
 produces: 


 # my_diagram.wdot - if .. then .. else
 :head  "My Diagram", LR {
 _start "Start"
 _end "Done"
 proc1 "Complex\nprocessing\nhere."
 if_check_ok

 _start->proc1 
 proc1->if_check_ok
 if_check_ok->_end "Y"
 if_check_ok->proc1 "N: redo"
 }
 produces: 


 # my_diagram.wdot - comments
 /* My workflow diagram.
  */
 :head  "My Diagram", LR {
 // Nodes - note: leading whitespace or blank lines not significant
 _start "Start"
 _end "Done"
 proc1 "Complex\nprocessing\nhere."
 if_check_ok "Check:\na. This\nb. That\nAll OK?"

 // Links
 _start->proc1 
 proc1->if_check_ok
 if_check_ok->_end "Y"
 if_check_ok->proc1 "N: redo"
 }
 produces: 


 # my_diagram.wdot - override using underlying dot for flexibility.
 /* My workflow diagram.
  */
 :head  "My Diagram", LR {
 // Nodes - note: leading whitespace or blank lines not significant
 _start "Start"
 _end "Done"
 proc1 [label="Dangerous Process" fillcolor="red" shape="hexagon"]
 if_check_ok "Check:\na. This\nb. That\nAll OK?"

 // Links
 _start->proc1 
 proc1->if_check_ok
 if_check_ok->_end "Y"
 if_check_ok->proc1 [label="N: redo" fontcolor="red" color="magenta" style="bold" arrowtail="inv"]
 }
 produces: 

Frequently Asked Questions?

See here.

Requirements