Wrap lines in the generated WADL file

This commit is contained in:
Cyril Roelandt 2013-10-16 20:28:16 +00:00
parent 16c1a9c062
commit 819e98a84e
2 changed files with 13 additions and 3 deletions

View File

@ -0,0 +1 @@
pytidylib>=0.2.1

View File

@ -19,7 +19,7 @@ from docutils.nodes import SparseNodeVisitor, StopTraversal
import json
import os
from sphinx.builders import Builder
from xml.dom import minidom
import tidylib
import xml.etree.ElementTree as ET
@ -139,8 +139,17 @@ class MyNodeVisitor(SparseNodeVisitor):
# Finally, write the output.
with open(output_file, 'w+') as f:
parsed_string = minidom.parseString(ET.tostring(self.root))
f.write(parsed_string.toprettyxml(" "))
options = {
'add-xml-decl': False,
'indent': True,
'indent-spaces': 4,
'input-xml': True,
'output-xml': True,
'wrap': 70
}
xml_str = tidylib.tidy_document(ET.tostring(self.root),
options=options)[0]
f.write(xml_str)
# If we're inside a bullet list, all the "paragraph" elements will be
# parameters description, so we need to know whether we currently are in a