summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorOlli Salli <ollisal@gmail.com>2011-08-01 23:39:05 +0300
committerOlli Salli <ollisal@gmail.com>2011-08-01 23:39:05 +0300
commita6f2171113a942fbd40086eafaf9ffb7667f82f9 (patch)
tree57e2a141b79b3b94e9c0daa5d397d67209cd24e6 /tools
parent9f15eb70bc4eac47639ee54a54c82dff51fd7d42 (diff)
format_docstring: Escape backslashes in full tp:docstring XML subtree, not after toxml()
This allows us to insert doxygen commands to the subtree. Previously, their leading '\' would be converted to '\\' as well.
Diffstat (limited to 'tools')
-rw-r--r--tools/libqt4codegen.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/tools/libqt4codegen.py b/tools/libqt4codegen.py
index c508c5c9..b39224cb 100644
--- a/tools/libqt4codegen.py
+++ b/tools/libqt4codegen.py
@@ -160,6 +160,18 @@ def format_docstring(el, indent=' * ', brackets=None, maxwidth=80):
lines = []
+ # escape backslashes, so they won't be interpreted starting doxygen commands and we can later
+ # insert doxygen commands we actually want
+ def escape_slashes(x):
+ if x.nodeType == x.TEXT_NODE:
+ x.data = x.data.replace('\\', '\\\\')
+ elif x.nodeType == x.ELEMENT_NODE:
+ for y in x.childNodes:
+ escape_slashes(y)
+ else:
+ return
+
+ escape_slashes(docstring_el)
doc = docstring_el.ownerDocument
for n in docstring_el.getElementsByTagNameNS(NS_TP, 'rationale'):
@@ -179,7 +191,7 @@ def format_docstring(el, indent=' * ', brackets=None, maxwidth=80):
splitted = ''.join([el.toxml() for el in docstring_el.childNodes]).strip(' ').strip('\n').split('\n')
level = min([not match and maxint or match.end() - 1 for match in [re.match('^ *[^ ]', line) for line in splitted]])
assert level != maxint
- lines = ['\htmlonly'] + [line[level:].replace('\\', '\\\\') for line in splitted] + ['\endhtmlonly']
+ lines = ['\\htmlonly'] + [line[level:] for line in splitted] + ['\\endhtmlonly']
else:
content = xml_escape(get_descendant_text(docstring_el).replace('\n', ' ').strip())
@@ -202,7 +214,7 @@ def format_docstring(el, indent=' * ', brackets=None, maxwidth=80):
content = content[step:]
if line:
- lines.append(line.replace('\\', '\\\\'))
+ lines.append(line)
output = []