Skip to content

Commit

Permalink
Render pages content in order
Browse files Browse the repository at this point in the history
When rendering Doxygen pages one expects content to appear in the
written order. As of today `para` sections content was grouped
separately depending on its type, causing out-of-order content in some
pages.

Signed-off-by: Gerard Marull-Paretas <[email protected]>
  • Loading branch information
gmarull committed Mar 3, 2021
1 parent 4ce8c7a commit a46be23
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
7 changes: 7 additions & 0 deletions breathe/parser/compound.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,8 @@ def __init__(self, char=None, valueOf_=''):
self.programlisting = []
self.images = []

self.ordered_children = []

def buildChildren(self, child_, nodeName_):
supermod.docParaType.buildChildren(self, child_, nodeName_)

Expand Down Expand Up @@ -1058,6 +1060,11 @@ def buildChildren(self, child_, nodeName_):
obj_ = supermod.docTableType.factory()
obj_.build(child_)
self.content.append(obj_)
else:
obj_ = None

if obj_:
self.ordered_children.append(obj_)


supermod.docParaType.subclass = docParaTypeSub
Expand Down
33 changes: 19 additions & 14 deletions breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,22 +1290,27 @@ def visit_docpara(self, node) -> List[Node]:
neighbouring instances of these things tend to each be in a separate neighbouring para tag.
"""

nodelist = self.render_iterable(node.content)
nodelist.extend(self.render_iterable(node.images))
nodelist = []

if self.app.config.breathe_order_parameters_first: # type: ignore
# Order parameters before simplesects, which mainly are return/warnings/remarks
definition_nodes = self.render_iterable(node.parameterlist)
definition_nodes.extend(self.render_iterable(node.simplesects))
if self.context and self.context.directive_args[0] == "doxygenpage":
nodelist.extend(self.render_iterable(node.ordered_children))
else:
# Returns, user par's, etc
definition_nodes = self.render_iterable(node.simplesects)
# Parameters/Exceptions
definition_nodes.extend(self.render_iterable(node.parameterlist))

if definition_nodes:
definition_list = nodes.definition_list("", *definition_nodes)
nodelist.append(definition_list)
nodelist.extend(self.render_iterable(node.content))
nodelist.extend(self.render_iterable(node.images))

if self.app.config.breathe_order_parameters_first: # type: ignore
# Order parameters before simplesects, which mainly are return/warnings/remarks
definition_nodes = self.render_iterable(node.parameterlist)
definition_nodes.extend(self.render_iterable(node.simplesects))
else:
# Returns, user par's, etc
definition_nodes = self.render_iterable(node.simplesects)
# Parameters/Exceptions
definition_nodes.extend(self.render_iterable(node.parameterlist))

if definition_nodes:
definition_list = nodes.definition_list("", *definition_nodes)
nodelist.append(definition_list)

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

Expand Down

0 comments on commit a46be23

Please sign in to comment.