diff options
author | Greg Hudson <ghudson@mit.edu> | 2021-03-06 02:20:28 -0500 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2021-03-08 18:53:14 -0500 |
commit | 2e0b22dc400b3a1b9615506fb4b65bdbddd2e73a (patch) | |
tree | 6919672dd46e258e295964dfd74f0a45c0a7be0e /doc | |
parent | 414cf4152c9743ca3aaef4cf9fb13628ec5f7896 (diff) | |
download | krb5-2e0b22dc400b3a1b9615506fb4b65bdbddd2e73a.zip krb5-2e0b22dc400b3a1b9615506fb4b65bdbddd2e73a.tar.gz krb5-2e0b22dc400b3a1b9615506fb4b65bdbddd2e73a.tar.bz2 |
Fix verbatim tag handling in Doxygen bridge
Commit 281210909beef4683be3b63bc1ac1e75c2c9c7eb added handling for
verbatim tags in doxybuilder_types.py, but did not check for tail
text. This wasn't a problem in Doxygen 1.8 because its XML output
ended paragraph tags after verbatim tags, but that isn't the case in
Doxygen 1.9. Move the is_tail check earlier so we don't have to check
for each tag type.
Also avoid putting spaces at the beginnings and ends of lines when
joining the elements of the result list, to avoid confusing the RST
parser at the end of literal blocks.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/tools/doxybuilder_types.py | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/doc/tools/doxybuilder_types.py b/doc/tools/doxybuilder_types.py index 063ee4b..6fa2f02 100644 --- a/doc/tools/doxybuilder_types.py +++ b/doc/tools/doxybuilder_types.py @@ -268,38 +268,36 @@ class DoxyTypes(object): def _process_paragraph_content(self, node): + def add_text(l, s): + # Add a space if it wouldn't be at the start or end of a line. + if l and not l[-1].endswith('\n') and not s.startswith('\n'): + l.append(' ') + l.append(s) + result = list() content = node.xpath(".//text()") for e in content: - if node is e.getparent(): - result.append(e.strip()) + if e.is_tail or node is e.getparent(): + add_text(result, e.strip()) elif e.getparent().tag == 'ref': - if e.is_tail: - result.append(e.strip()) - elif e.strip().find('(') > 0: - result.append(':c:func:`%s`' % e.strip()) + if e.strip().find('(') > 0: + add_text(result, ':c:func:`%s`' % e.strip()) elif e.isupper(): - result.append(':c:data:`%s`' % e.strip()) + add_text(result, ':c:data:`%s`' % e.strip()) else: - result.append(':c:type:`%s`' % e.strip()) + add_text(result, ':c:type:`%s`' % e.strip()) elif e.getparent().tag == 'emphasis': - if e.is_tail: - result.append(e.strip()) - else: - result.append('*%s*' % e.strip()) + add_text(result, '*%s*' % e.strip()) elif e.getparent().tag == 'computeroutput': - if e.is_tail: - result.append(e.strip()) - else: - result.append('*%s*' % e.strip()) - elif e.getparent().tag == 'defname': - result.append('%s, ' % e.strip()) + add_text(result, '*%s*' % e.strip()) + elif e.getparent().tag == 'defname': + add_text(result, '%s, ' % e.strip()) elif e.getparent().tag == 'verbatim': - result.append('\n::\n\n') - result.append(textwrap.indent(e, ' ', lambda x: True)) - result.append('\n') + add_text(result, '\n::\n\n') + add_text(result, textwrap.indent(e, ' ', lambda x: True)) + add_text(result, '\n') - result = ' '.join(result) + result = ''.join(result) return result |