Skip to content

Commit

Permalink
Add rendering of \{sub}section
Browse files Browse the repository at this point in the history
\section, \subsection and \subsubsection are commands that can be added
to \page for creating multi-level section rendering, including a title
and content.

https://www.doxygen.nl/manual/commands.html#cmdsection
https://www.doxygen.nl/manual/commands.html#cmdsubsection
https://www.doxygen.nl/manual/commands.html#cmdsubsubsection

Implement the rendering using Docutils nodes.title() which already uses
the structure of the document to attribute a proper heading level, which
should not need extra handling since the Doxygen XML already guarantees
the proper structure.

Signed-off-by: Fabio Utzig <utzig@apache.org>
  • Loading branch information
utzig committed Feb 9, 2021
1 parent 3bd0273 commit 9b372f3
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1344,8 +1344,19 @@ def visit_docmarkup(self, node) -> List[Node]:
print("Warning: does not currently handle 'small' text display")
return [creator("", "", *nodelist)]

def visit_docsect1(self, node) -> List[Node]:
return []
def visit_docsectX(self, node) -> List[Node]:
'''
Docutils titles are defined by their level inside the document so
the proper structure is only guaranteed by the Doxygen XML.
Doxygen command mapping to XML element name:
@section == sect1, @subsection == sect2, @subsubsection == sect3
'''
section = nodes.section()
section['ids'].append(node.id)
section += nodes.title(node.title, node.title)
section += self.render_iterable(node.content_)
return [section]

def visit_docsimplesect(self, node) -> List[Node]:
"""Other Type documentation such as Warning, Note, Returns, etc"""
Expand Down Expand Up @@ -1986,7 +1997,9 @@ def dispatch_memberdef(self, node) -> List[Node]:
"docimage": visit_docimage,
"docurllink": visit_docurllink,
"docmarkup": visit_docmarkup,
"docsect1": visit_docsect1,
"docsect1": visit_docsectX,
"docsect2": visit_docsectX,
"docsect3": visit_docsectX,
"docsimplesect": visit_docsimplesect,
"doctitle": visit_doctitle,
"docformula": visit_docformula,
Expand Down

0 comments on commit 9b372f3

Please sign in to comment.