Skip to content

Commit

Permalink
Merge pull request #833 from jakobandersen/fix-literal-in-paragraph
Browse files Browse the repository at this point in the history
Pull lone literal_blocks out of paragraphs
  • Loading branch information
jakobandersen authored Jul 24, 2022
2 parents da73e58 + ad551f4 commit a94ae67
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Change Log

Inspired by `Keepachangelog.com <http://keepachangelog.com/>`__.

- Unreleased

- Pull lone literal blocks in paragraphs up to produce correct doctree.
`#833 <https://github.com/michaeljones/breathe/pull/833>`__

- 2022-06-20 - **Breathe v4.34.0**

- Treat .unparsed as plain text.
Expand Down
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 a94ae67

Please sign in to comment.