Dot

Dot is component of GraphViz, and can be used to automatically generate directional graph diagrams from a simple textual DSL. Here is an example of the DSL you can use to generate a Dot graph (look familiar?):

digraph g{
	Story[label="Story(string title)"]
	Condition[label="Condition(string text, Action action)"]
	Operation[label="Operation(string text, Action action)"]
	Outcome[label="Outcome(string text, Action action)"]
	Story -> Condition [label="Given"]
	Condition -> Condition [label="And"]
	Condition -> Operation [label="When"]
	Operation -> Operation [label="And"]
	Operation -> Outcome [label="Then"]
	Outcome -> Outcome [label="And"]
}



And executing Dot against this text file (dot -O -Tpng source.txt) will produce:

GivenWhenThen.txt.png

One of the neat things about Dot is that it you don't have to provide any aesthetic information to it, and it will automatically lay out your nodes and edges in a relatively pleasing manner. That's why we decided to use a DSL that was directly compatible with Dot for Flit: You can simply run dot against your source DSL files to get an easy to understand diagram of your fluent interface.

You can read more about the full syntax of Dot at the GraphViz documentation page. You'll see that there's lots of attributes you can apply to a Dot graph, colours, shapes, fonts etc. All of these are (currently) ignored by Flit, except for the Label. You may wish to take advantage of these other attributes for documentation purposes. Flit uses the Label to determine the method or class name, and also to find out what parameters the method or class requires. You can read more about that at the Parser wiki page.

Last edited Oct 17, 2009 at 7:48 PM by robfe, version 6

Comments

No comments yet.