Skip to content

Commit

Permalink
Pull lone literal_blocks out of paragraphs
Browse files Browse the repository at this point in the history
Fixes #827
  • Loading branch information
jakobandersen committed Apr 23, 2022
1 parent d3022c1 commit 35047fd
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,23 @@ def visit_docpara(self, node) -> List[Node]:
nodelist.extend(paramList)
nodelist.extend(fields)

# And now all kinds of cleanup steps
# ----------------------------------

# trim trailing whitespace
while len(nodelist) != 0:
last = nodelist[-1]
if not isinstance(last, nodes.Text):
break
if last.astext().strip() != '':
break
nodelist.pop()

# https://github.com/michaeljones/breathe/issues/827
# verbatim nodes should not be in a paragraph:
if len(nodelist) == 1 and isinstance(nodelist[0], nodes.literal_block):
return nodelist

return [nodes.paragraph("", "", *nodelist)]

def visit_docparblock(self, node) -> List[Node]:
Expand Down

0 comments on commit 35047fd

Please sign in to comment.