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

Handle directives returning no nodes on error #672

Merged
merged 1 commit into from
Apr 9, 2021
Merged
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
23 changes: 16 additions & 7 deletions breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,14 +605,19 @@ def run_directive(self, obj_type: str, declaration: str, contentCallback: Conten
_debug_indent -= 1

# Filter out outer class names if we are rendering a member as a part of a class content.
rst_node = nodes[1]
finder = NodeFinder(rst_node.document)
rst_node.walk(finder)
# In some cases of errors with a declaration there are no nodes
# (e.g., variable in function), so perhaps skip (see #671).
# If there are nodes, there should be at least 2.
if len(nodes) != 0:
assert len(nodes) >= 2, nodes
rst_node = nodes[1]
finder = NodeFinder(rst_node.document)
rst_node.walk(finder)

signode = finder.declarator
signode = finder.declarator

if self.context.child:
signode.children = [n for n in signode.children if not n.tagname == 'desc_addname']
if self.context.child:
signode.children = [n for n in signode.children if not n.tagname == 'desc_addname']
return nodes

def handle_declaration(self, node, declaration: str, *, obj_type: str = None,
Expand All @@ -639,7 +644,11 @@ def content(contentnode):

# <desc><desc_signature> and then one or more <desc_signature_line>
# each <desc_signature_line> has a sphinx_line_type which hints what is present in that line
assert len(nodes_) >= 1
# In some cases of errors with a declaration there are no nodes
# (e.g., variable in function), so perhaps skip (see #671).
if len(nodes_) == 0:
return []
assert len(nodes_) >= 2, nodes_
desc = nodes_[1]
assert isinstance(desc, addnodes.desc)
assert len(desc) >= 1
Expand Down