summaryrefslogtreecommitdiff
path: root/sphinx/addnodes.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-01-24 16:34:47 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-01-24 16:34:47 +0900
commit51d500833e391c182f536e83a5d62d5e90ce8ca9 (patch)
treefb854309b759773feb83e7e4bbc91e3ed3cb2b00 /sphinx/addnodes.py
parent375fb52fe402d46d633e321ce8f20c1aa61c49b9 (diff)
parent41ee2d6e6595d0eefb4a2b752fd79a3451382d5a (diff)
downloadsphinx-git-51d500833e391c182f536e83a5d62d5e90ce8ca9.tar.gz
Merge branch '3.x' into 7774_remove_develop.rst
Diffstat (limited to 'sphinx/addnodes.py')
-rw-r--r--sphinx/addnodes.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/sphinx/addnodes.py b/sphinx/addnodes.py
index 5e191e989..5f371e46b 100644
--- a/sphinx/addnodes.py
+++ b/sphinx/addnodes.py
@@ -4,7 +4,7 @@
Additional docutils nodes.
- :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -21,6 +21,33 @@ if False:
from sphinx.application import Sphinx
+class document(nodes.document):
+ """The document root element patched by Sphinx.
+
+ This fixes that document.set_id() does not support a node having multiple node Ids.
+ see https://sourceforge.net/p/docutils/patches/167/
+
+ .. important:: This is only for Sphinx internal use. Please don't use this
+ in your extensions. It will be removed without deprecation period.
+ """
+
+ def set_id(self, node: Element, msgnode: Element = None,
+ suggested_prefix: str = '') -> str:
+ from sphinx.util import docutils
+ if docutils.__version_info__ >= (0, 16):
+ ret = super().set_id(node, msgnode, suggested_prefix) # type: ignore
+ else:
+ ret = super().set_id(node, msgnode)
+
+ if docutils.__version_info__ < (0, 17):
+ # register other node IDs forcedly
+ for node_id in node['ids']:
+ if node_id not in self.ids:
+ self.ids[node_id] = node
+
+ return ret
+
+
class translatable(nodes.Node):
"""Node which supports translation.