diff --git a/breathe/renderer/sphinxrenderer.py b/breathe/renderer/sphinxrenderer.py index 509ce6dc..467c545a 100644 --- a/breathe/renderer/sphinxrenderer.py +++ b/breathe/renderer/sphinxrenderer.py @@ -615,7 +615,7 @@ def run_directive( _debug_indent += 1 self.nesting_level += 1 - nodes = directive.run() + nodes_ = directive.run() self.nesting_level -= 1 # TODO: the directive_args seems to be reused between different run_directives @@ -631,9 +631,9 @@ def run_directive( # 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] + if len(nodes_) != 0: + assert len(nodes_) >= 2, nodes_ + rst_node = nodes_[1] finder = NodeFinder(rst_node.document) rst_node.walk(finder) @@ -641,7 +641,7 @@ def run_directive( if self.context.child: signode.children = [n for n in signode.children if not n.tagname == "desc_addname"] - return nodes + return nodes_ def handle_declaration( self, @@ -806,8 +806,8 @@ def get_fully_qualified_name(self): def create_template_prefix(self, decl) -> str: if not decl.templateparamlist: return "" - nodes = self.render(decl.templateparamlist) - return "template<" + "".join(n.astext() for n in nodes) + ">" + nodes_ = self.render(decl.templateparamlist) + return "template<" + "".join(n.astext() for n in nodes_) + ">" def run_domain_directive(self, kind, names): domain_directive = DomainDirectiveFactory.create( @@ -828,13 +828,13 @@ def run_domain_directive(self, kind, names): ) _debug_indent += 1 - nodes = domain_directive.run() + nodes_ = domain_directive.run() if config.breathe_debug_trace_directives: _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] + rst_node = nodes_[1] finder = NodeFinder(rst_node.document) rst_node.walk(finder) @@ -842,7 +842,7 @@ def run_domain_directive(self, kind, names): if len(names) > 0 and self.context.child: signode.children = [n for n in signode.children if not n.tagname == "desc_addname"] - return nodes + return nodes_ def create_doxygen_target(self, node): """Can be overridden to create a target node which uses the doxygen refid information @@ -926,7 +926,7 @@ def render_declaration(self, node, declaration=None, description=None, **kwargs) obj_type = kwargs.get("objtype", None) if obj_type is None: obj_type = node.kind - nodes = self.run_domain_directive(obj_type, [declaration.replace("\n", " ")]) + nodes_ = self.run_domain_directive(obj_type, [declaration.replace("\n", " ")]) if self.app.env.config.breathe_debug_trace_doxygen_ids: target = self.create_doxygen_target(node) if len(target) == 0: @@ -934,7 +934,7 @@ def render_declaration(self, node, declaration=None, description=None, **kwargs) else: print("{}Doxygen target (old): {}".format(" " * _debug_indent, target[0]["ids"])) - rst_node = nodes[1] + rst_node = nodes_[1] finder = NodeFinder(rst_node.document) rst_node.walk(finder) @@ -950,7 +950,7 @@ def render_declaration(self, node, declaration=None, description=None, **kwargs) target = self.create_doxygen_target(node) signode.insert(0, target) contentnode.extend(description) - return nodes + return nodes_ def visit_doxygen(self, node) -> List[Node]: nodelist: List[Node] = [] @@ -989,8 +989,8 @@ def content(contentnode): rendered_data = self.render(file_data, parent_context) contentnode.extend(rendered_data) - nodes = self.handle_declaration(nodeDef, declaration, content_callback=content) - return nodes + nodes_ = self.handle_declaration(nodeDef, declaration, content_callback=content) + return nodes_ def visit_class(self, node) -> List[Node]: # Read in the corresponding xml file and process @@ -1047,16 +1047,16 @@ def content(contentnode) -> None: assert kind in ("class", "struct", "interface") display_obj_type = "interface" if kind == "interface" else None - nodes = self.handle_declaration( + nodes_ = self.handle_declaration( nodeDef, declaration, content_callback=content, display_obj_type=display_obj_type ) if "members-only" in self.context.directive_args[2]: - assert len(nodes) >= 2 - assert isinstance(nodes[1], addnodes.desc) - assert len(nodes[1]) >= 2 - assert isinstance(nodes[1][1], addnodes.desc_content) - return nodes[1][1].children - return nodes + assert len(nodes_) >= 2 + assert isinstance(nodes_[1], addnodes.desc) + assert len(nodes_[1]) >= 2 + assert isinstance(nodes_[1][1], addnodes.desc_content) + return nodes_[1][1].children + return nodes_ def visit_namespace(self, node) -> List[Node]: # Read in the corresponding xml file and process @@ -1087,10 +1087,10 @@ def content(contentnode): contentnode.extend(rendered_data) display_obj_type = "namespace" if self.get_domain() != "py" else "module" - nodes = self.handle_declaration( + nodes_ = self.handle_declaration( nodeDef, declaration, content_callback=content, display_obj_type=display_obj_type ) - return nodes + return nodes_ def visit_compound(self, node, render_empty_node=True, **kwargs) -> List[Node]: # Read in the corresponding xml file and process @@ -1144,8 +1144,8 @@ def render_signature(file_data, doxygen_target, name, kind): self.context.directive_args[1] = [arg] - nodes = self.run_domain_directive(kind, self.context.directive_args[1]) - rst_node = nodes[1] + nodes_ = self.run_domain_directive(kind, self.context.directive_args[1]) + rst_node = nodes_[1] finder = NodeFinder(rst_node.document) rst_node.walk(finder) @@ -1156,14 +1156,14 @@ def render_signature(file_data, doxygen_target, name, kind): finder.declarator[0] = addnodes.desc_annotation(kind + " ", kind + " ") rst_node.children[0].insert(0, doxygen_target) - return nodes, finder.content + return nodes_, finder.content refid = self.get_refid(node.refid) render_sig = kwargs.get("render_signature", render_signature) with WithContext(self, new_context): # Pretend that the signature is being rendered in context of the # definition, for proper domain detection - nodes, contentnode = render_sig( + nodes_, contentnode = render_sig( file_data, self.target_handler.create_target(refid), name, kind ) @@ -1172,7 +1172,7 @@ def render_signature(file_data, doxygen_target, name, kind): contentnode.extend(self.render(include, new_context.create_child_context(include))) contentnode.extend(rendered_data) - return nodes + return nodes_ def visit_file(self, node) -> List[Node]: def render_signature(file_data, doxygen_target, name, kind): @@ -1964,8 +1964,8 @@ def visit_function(self, node) -> List[Node]: elements.append(name) elements.append(node.get_argsstring()) declaration = " ".join(elements) - nodes = self.handle_declaration(node, declaration) - return nodes + nodes_ = self.handle_declaration(node, declaration) + return nodes_ else: # Get full function signature for the domain directive. param_list = [] @@ -2000,7 +2000,7 @@ def visit_function(self, node) -> List[Node]: self.context = cast(RenderContext, self.context) self.context.directive_args[1] = [signature] - nodes = self.run_domain_directive(node.kind, self.context.directive_args[1]) + nodes_ = self.run_domain_directive(node.kind, self.context.directive_args[1]) assert self.app.env is not None if self.app.env.config.breathe_debug_trace_doxygen_ids: @@ -2012,7 +2012,7 @@ def visit_function(self, node) -> List[Node]: "{}Doxygen target (old): {}".format(" " * _debug_indent, target[0]["ids"]) ) - rst_node = nodes[1] + rst_node = nodes_[1] finder = NodeFinder(rst_node.document) rst_node.walk(finder) @@ -2023,7 +2023,7 @@ def visit_function(self, node) -> List[Node]: rst_node.children[0].insert(0, target) finder.content.extend(self.description(node)) - return nodes + return nodes_ def visit_define(self, node) -> List[Node]: declaration = node.name