Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rendering of \section, \subsection and \subsubsection #635

Merged
merged 2 commits into from
Feb 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions breathe/parser/compoundsuper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2888,6 +2888,10 @@ def __init__(self, id=None, title=None, para=None, sect2=None, internal=None, mi
self.content_ = []
else:
self.content_ = content_
if title is None:
self.title = ""
else:
self.title = title
def factory(*args_, **kwargs_):
if docSect1Type.subclass:
return docSect1Type.subclass(*args_, **kwargs_)
Expand Down Expand Up @@ -2943,11 +2947,7 @@ def buildAttributes(self, attrs):
def buildChildren(self, child_, nodeName_):
if child_.nodeType == Node.ELEMENT_NODE and \
nodeName_ == 'title':
childobj_ = docTitleType.factory()
childobj_.build(child_)
obj_ = self.mixedclass_(MixedContainer.CategoryComplex,
MixedContainer.TypeNone, 'title', childobj_)
self.content_.append(obj_)
self.title = child_.childNodes[0].nodeValue
elif child_.nodeType == Node.ELEMENT_NODE and \
nodeName_ == 'para':
childobj_ = docParaType.factory()
Expand Down Expand Up @@ -2989,6 +2989,10 @@ def __init__(self, id=None, title=None, para=None, sect3=None, internal=None, mi
self.content_ = []
else:
self.content_ = content_
if title is None:
title = ""
else:
title = title
def factory(*args_, **kwargs_):
if docSect2Type.subclass:
return docSect2Type.subclass(*args_, **kwargs_)
Expand Down Expand Up @@ -3044,11 +3048,7 @@ def buildAttributes(self, attrs):
def buildChildren(self, child_, nodeName_):
if child_.nodeType == Node.ELEMENT_NODE and \
nodeName_ == 'title':
childobj_ = docTitleType.factory()
childobj_.build(child_)
obj_ = self.mixedclass_(MixedContainer.CategoryComplex,
MixedContainer.TypeNone, 'title', childobj_)
self.content_.append(obj_)
self.title = child_.childNodes[0].nodeValue
elif child_.nodeType == Node.ELEMENT_NODE and \
nodeName_ == 'para':
childobj_ = docParaType.factory()
Expand Down Expand Up @@ -3090,6 +3090,10 @@ def __init__(self, id=None, title=None, para=None, sect4=None, internal=None, mi
self.content_ = []
else:
self.content_ = content_
if title is None:
self.title = ""
else:
self.title = title
def factory(*args_, **kwargs_):
if docSect3Type.subclass:
return docSect3Type.subclass(*args_, **kwargs_)
Expand Down Expand Up @@ -3145,11 +3149,7 @@ def buildAttributes(self, attrs):
def buildChildren(self, child_, nodeName_):
if child_.nodeType == Node.ELEMENT_NODE and \
nodeName_ == 'title':
childobj_ = docTitleType.factory()
childobj_.build(child_)
obj_ = self.mixedclass_(MixedContainer.CategoryComplex,
MixedContainer.TypeNone, 'title', childobj_)
self.content_.append(obj_)
self.title = child_.childNodes[0].nodeValue
elif child_.nodeType == Node.ELEMENT_NODE and \
nodeName_ == 'para':
childobj_ = docParaType.factory()
Expand Down
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_docsectN(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_docsectN,
"docsect2": visit_docsectN,
"docsect3": visit_docsectN,
"docsimplesect": visit_docsimplesect,
"doctitle": visit_doctitle,
"docformula": visit_docformula,
Expand Down