chiark / gitweb /
m.dot: make title optional.
authorVladimír Vondruš <mosra@centrum.cz>
Sun, 14 Oct 2018 14:32:10 +0000 (16:32 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Sun, 14 Oct 2018 18:17:49 +0000 (20:17 +0200)
Requiring a title won't make any sense for graph figures.

doc/plugins/plots-and-graphs.rst
pelican-plugins/m/dot.py
pelican-plugins/m/test/dot/page-236.html
pelican-plugins/m/test/dot/page-238.html
pelican-plugins/m/test/dot/page.html
pelican-plugins/m/test/dot/page.rst

index b2ac33941acc7641315797a1500d4839e83e8909..3d00e267ef3fac50b21b8e3b6544366736356df4 100644 (file)
@@ -199,7 +199,7 @@ The plugin produces SVG graphcs that make use of the
 --------------------
 
 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
index 04e2a41eeba490ca940543efd9ad2943819f55de..b5f8855bf57e7c5b61e2ce9af8799d6ea6683f29 100644 (file)
@@ -35,7 +35,7 @@ import dot2svg
 
 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}
@@ -53,19 +53,35 @@ class Dot(rst.Directive):
 
 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(
index e740ce422dfbe4605c55b34331566a0e2253baa1..1963b629e912d57c03d425377d6a320e7bdb82d2 100644 (file)
@@ -97,11 +97,10 @@ and the arrowheads, nothing else. Non-default font size should be preserved.</p>
 </g>
 </svg>
 </div>
-<p>Unoriented graph:</p>
+<p>Unoriented graph without a title:</p>
 <div class="m-graph m-success">
 <svg style="width: 3.875rem; height: 7.500rem;" viewBox="0.00 0.00 62.00 120.00">
 <g transform="scale(1 1) rotate(0) translate(4 116)">
-<title>A to B</title>
 <g class="m-node m-flat">
 <title>a</title>
 <ellipse cx="27" cy="-93" rx="27" ry="18.2703"/>
index 5fa3e77924eaf93bb8da9972f3f6b5a319afa642..c0c85a9d86b2de3b9d3b3e526e49787d28e1415a 100644 (file)
@@ -97,11 +97,10 @@ and the arrowheads, nothing else. Non-default font size should be preserved.</p>
 </g>
 </svg>
 </div>
-<p>Unoriented graph:</p>
+<p>Unoriented graph without a title:</p>
 <div class="m-graph m-success">
 <svg style="width: 3.875rem; height: 7.375rem;" viewBox="0.00 0.00 62.00 117.54">
 <g transform="scale(1 1) rotate(0) translate(4 113.539)">
-<title>A to B</title>
 <g class="m-node m-flat">
 <title>a</title>
 <ellipse cx="27" cy="-91.1543" rx="27" ry="18.2703"/>
index 664d8351d5dea272ee26014e49d5629c1a0d9e60..4c5ecc00560d9efdda9b5cb5c5e1b6603c050343 100644 (file)
@@ -97,11 +97,10 @@ and the arrowheads, nothing else. Non-default font size should be preserved.</p>
 </g>
 </svg>
 </div>
-<p>Unoriented graph:</p>
+<p>Unoriented graph without a title:</p>
 <div class="m-graph m-success">
 <svg style="width: 3.875rem; height: 7.375rem;" viewBox="0.00 0.00 62.00 117.54">
 <g transform="scale(1 1) rotate(0) translate(4 113.5391)">
-<title>A to B</title>
 <g class="m-node m-flat">
 <title>a</title>
 <ellipse cx="27" cy="-91.1543" rx="27" ry="18.2703"/>
index 42e3964940322c4ae594ce64ddacd0802c774139..87e2c7fd08881e96a7d56605711d2af5b143f913 100644 (file)
@@ -27,9 +27,9 @@ Colors:
     a -> b [class="m-warning" label="yes"]
     b -> b [class="m-primary" label="no"]
 
-Unoriented graph:
+Unoriented graph without a title:
 
-.. graph:: A to B
+.. graph::
     :class: m-success
 
     a -- b