Commits

Georg Brandl committed 4ff56bf

Fix #720: add dummy visitor for graphviz nodes for man/text writer.

  • Participants
  • Parent commits 79b0d10

Comments (0)

Files changed (4)

 Release 1.0.8 (in development)
 ==============================
 
+* #720: Add dummy visitors for graphviz nodes for text and man.
+
 * #704: Fix image file duplication bug.
 
 * #677: Fix parsing of multiple signatures in C++ domain.

File sphinx/ext/graphviz.py

 from docutils.parsers.rst import directives
 
 from sphinx.errors import SphinxError
+from sphinx.locale import _
 from sphinx.util.osutil import ensuredir, ENOENT, EPIPE
 from sphinx.util.compat import Directive
 
 def latex_visit_graphviz(self, node):
     render_dot_latex(self, node, node['code'], node['options'])
 
+
+def text_visit_graphviz(self, node):
+    if 'alt' in node.attributes:
+        self.add_text(_('[graph: %s]') % node['alt'])
+    self.add_text(_('[graph]'))
+    raise nodes.SkipNode
+
+
+def man_visit_graphviz(self, node):
+    if 'alt' in node.attributes:
+        self.body.append(_('[graph: %s]') % node['alt'] + '\n')
+    self.body.append(_('[graph]'))
+    raise nodes.SkipNode
+
+
 def setup(app):
     app.add_node(graphviz,
                  html=(html_visit_graphviz, None),
-                 latex=(latex_visit_graphviz, None))
+                 latex=(latex_visit_graphviz, None),
+                 text=(text_visit_graphviz, None),
+                 man=(man_visit_graphviz, None))
     app.add_directive('graphviz', Graphviz)
     app.add_directive('graph', GraphvizSimple)
     app.add_directive('digraph', GraphvizSimple)

File sphinx/writers/manpage.py

     # overwritten -- don't emit a warning for images
     def visit_image(self, node):
         if 'alt' in node.attributes:
-            self.body.append('[image: %s]\n' % node['alt'])
-        self.body.append('[image]\n')
+            self.body.append(_('[image: %s]') % node['alt'] + '\n')
+        self.body.append(_('[image]') + '\n')
         raise nodes.SkipNode
 
     # overwritten -- don't visit inner marked up nodes

File sphinx/writers/text.py

         raise nodes.SkipNode
 
     def visit_image(self, node):
+        if 'alt' in node.attributes:
+            self.add_text(_('[image: %s]') % node['alt'])
         self.add_text(_('[image]'))
         raise nodes.SkipNode