We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
nodes.Element
1 parent 2a7c40d commit dcb4429Copy full SHA for dcb4429
1 file changed
sphinx/util/nodes.py
@@ -608,3 +608,18 @@ def process_only_nodes(document: Node, tags: Tags) -> None:
608
# the only node, so we make sure docutils can transfer the id to
609
# something, even if it's just a comment and will lose the id anyway...
610
node.replace_self(nodes.comment())
611
+
612
613
+def _copy_except__document(self: Element) -> Element:
614
+ """Monkey-patch ```nodes.Element.copy``` to not copy the ``_document``
615
+ attribute.
616
617
+ xref: https://github.com/sphinx-doc/sphinx/issues/11116#issuecomment-1376767086
618
+ """
619
+ newnode = self.__class__(rawsource=self.rawsource, **self.attributes)
620
+ newnode.source = self.source
621
+ newnode.line = self.line
622
+ return newnode
623
624
625
+nodes.Element.copy = _copy_except__document # type: ignore
0 commit comments