Jon Waltman avatar Jon Waltman committed baedd56

xml: Fix compatibility with docutils<0.9

Comments (0)

Files changed (2)


 import codecs
 from os import path
+from docutils import nodes
 from import StringOutput
 from import Builder
         self.writer = self._writer_class(self)
     def write_doc(self, docname, doctree):
+        # work around multiple string % tuple issues in docutils;
+        # replace tuples in attribute values with lists
+        doctree = doctree.deepcopy()
+        for node in doctree.traverse(nodes.Element):
+            for att, value in node.attributes.items():
+                if isinstance(value, tuple):
+                    node.attributes[att] = list(value)
+                value = node.attributes[att]
+                if isinstance(value, list):
+                    for i, val in enumerate(value):
+                        if isinstance(val, tuple):
+                            value[i] = list(val)
         destination = StringOutput(encoding='utf-8')
         self.writer.write(doctree, destination)
         outfilename = path.join(self.outdir, os_path(docname) + self.out_suffix)


 from docutils import writers
 from docutils.writers.docutils_xml import Writer as BaseXMLWriter
-from docutils.writers.docutils_xml import XMLTranslator as BaseXMLTranslator
 class XMLWriter(BaseXMLWriter):
         return BaseXMLWriter.translate(self)
-class XMLTranslator(BaseXMLTranslator):
-    def __init__(self, builder, doc):
-        BaseXMLTranslator.__init__(self, doc)
-        self.builder = builder
 class PseudoXMLWriter(writers.Writer):
     supported = ('pprint', 'pformat', 'pseudoxml')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.