summaryrefslogtreecommitdiff
path: root/qt4
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
commit5f0f36a17ad5047c3665cbc66764d9f7c7154024 (patch)
treedca9d937907b90eb3c2c7b832aaf1afa68a0568a /qt4
parent6adcfc9003090250f3506b9332074b7729c25539 (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 'qt4')
-rw-r--r--qt4/tools/libqt4codegen.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/qt4/tools/libqt4codegen.py b/qt4/tools/libqt4codegen.py
index c508c5c95..b39224cbd 100644
--- a/qt4/tools/libqt4codegen.py
+++ b/qt4/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 = []