def depart_classifier(self, node: Element) -> None: self.body.append('</span>') next_node = node.next_node(descend=False, siblings=True) # type: Node if not isinstance(next_node, nodes.classifier): # close `<dt>` tag at the tail of classifiers self.body.append('</dt>')
def depart_term(self, node: Element) -> None: next_node = node.next_node(descend=False, siblings=True) # type: Node if isinstance(next_node, nodes.classifier): # Leave the end tag to `self.depart_classifier()`, in case # there's a classifier. pass else: self.body.append('</dt>')
def depart_desc_signature(self, node: Element) -> None: """Change permalinks for code definitions. Functions, methods, command line options, etc. "Copy link to this definition" """ dd = node.next_node(addnodes.desc_content, siblings=True) if self.config.html_collapsible_definitions and len(dd.astext()) > 0: self.body.append(EXPAND_MORE_BUTTON) super().depart_desc_signature(node)
def depart_desc_signature(self, node: Element) -> None: """Change permalinks for code definitions. Functions, methods, command line options, etc. "Copy link to this definition" """ if not node.get("is_multiline"): self.add_permalink_ref(node, _("Copy link to this definition.")) dd = node.next_node(addnodes.desc_content, siblings=True) if self.config.html_collapsible_definitions and len(dd.astext()) > 0: self.body.append(EXPAND_MORE_BUTTON) self.body.append("</dt>\n")
def depart_term(self, node: Element) -> None: next_node: Node = node.next_node(descend=False, siblings=True) if isinstance(next_node, nodes.classifier): # Leave the end tag to `self.depart_classifier()`, in case # there's a classifier. pass else: if isinstance(node.parent.parent.parent, addnodes.glossary): # add permalink if glossary terms self.add_permalink_ref(node, _('Permalink to this term')) self.body.append('</dt>')
def visit_desc_signature(self, node: Element) -> None: """Add the accordion class to the <dt> element. This will make the definition list collapsible, if the configuration option ``html_collapsible_definitions`` is set. """ # only add this, if the following dd is not empty. dd = node.next_node(addnodes.desc_content, siblings=True) if self.config.html_collapsible_definitions and len(dd.astext()) > 0: self.body.append(self.starttag(node, "dt", CLASS="accordion")) else: self.body.append(self.starttag(node, "dt"))
def visit_desc_signature(self, node: Element) -> None: """Add the accordion class to the <dt> element. This will make the definition list collapsible, if the configuration option ``html_collapsible_definitions`` is set. """ attrs = { "data-controller": "collapsible", "data-action": "click->collapsible#expandAccordion", } # only add this, if the following dd is not empty. dd = node.next_node(addnodes.desc_content, siblings=True) if self.config.html_collapsible_definitions and len(dd.astext()) > 0: self.body.append( self.starttag(node, "dt", CLASS="accordion", **attrs)) else: self.body.append(self.starttag(node, "dt")) self.protect_literal_text += 1