Skip to content

Commit

Permalink
Fix verbatim tag handling in Doxygen bridge
Browse files Browse the repository at this point in the history
Commit 2812109 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.
  • Loading branch information
greghudson committed Mar 8, 2021
1 parent 414cf41 commit 2e0b22d
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions doc/tools/doxybuilder_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,38 +268,36 @@ def _get_detailed_description(self, node):

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

Expand Down

0 comments on commit 2e0b22d

Please sign in to comment.