--------------------
The :rst:`.. digraph::` directive uses the ``dot`` tool to produce directed
-graphs. The required directive argument is graph title, contents is whatever
+graphs. The optional directive argument is graph title, contents is whatever
you would put inside the :dot:`digraph` block. Use the :rst:`:class:` to
specify a `CSS color class <{filename}/css/components.rst#colors>`_ for the
whole graph, it's also possible to color particular nodes and edges using the
class Dot(rst.Directive):
has_content = True
- required_arguments = 1
+ optional_arguments = 1
final_argument_whitespace = True
option_spec = {'class': directives.class_option,
'name': directives.unchanged}
class Digraph(Dot):
def run(self):
- return Dot.run(self, 'digraph "{}" {{\n{}}}'.format(self.arguments[0], '\n'.join(self.content)))
+ # We need to pass "" for an empty title to get rid of <title>,
+ # otherwise the output contains <title>%3</title> (wtf!)
+ return Dot.run(self, 'digraph "{}" {{\n{}}}'.format(
+ self.arguments[0] if self.arguments else '',
+ '\n'.join(self.content)))
class StrictDigraph(Dot):
def run(self):
- return Dot.run(self, 'strict digraph "{}" {{\n{}}}'.format(self.arguments[0], '\n'.join(self.content)))
+ # We need to pass "" for an empty title to get rid of <title>,
+ # otherwise the output contains <title>%3</title> (wtf!)
+ return Dot.run(self, 'strict digraph "{}" {{\n{}}}'.format(
+ self.arguments[0] if self.arguments else '',
+ '\n'.join(self.content)))
class Graph(Dot):
def run(self):
- return Dot.run(self, 'graph "{}" {{\n{}}}'.format(self.arguments[0], '\n'.join(self.content)))
+ # We need to pass "" for an empty title to get rid of <title>,
+ # otherwise the output contains <title>%3</title> (wtf!)
+ return Dot.run(self, 'graph "{}" {{\n{}}}'.format(
+ self.arguments[0] if self.arguments else '',
+ '\n'.join(self.content)))
class StrictGraph(Dot):
def run(self):
- return Dot.run(self, 'strict graph "{}" {{\n{}}}'.format(self.arguments[0], '\n'.join(self.content)))
+ # We need to pass "" for an empty title to get rid of <title>,
+ # otherwise the output contains <title>%3</title> (wtf!)
+ return Dot.run(self, 'strict graph "{}" {{\n{}}}'.format(
+ self.arguments[0] if self.arguments else '',
+ '\n'.join(self.content)))
def configure(pelicanobj):
dot2svg.configure(