summaryrefslogtreecommitdiff
path: root/sphinx/util/nodes.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-11-15 19:44:39 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-03-06 02:01:05 +0900
commitd99132680d277db8409d17195948ee1d422dca66 (patch)
treeab5ec3a2f5cabe16358d1e03f57ae419b1a7ba39 /sphinx/util/nodes.py
parente1130972b2ad2e57db4ebe0a6fa83e1cb76aa6a3 (diff)
downloadsphinx-git-d99132680d277db8409d17195948ee1d422dca66.tar.gz
Filter pending_xref_condition node on failed resolution
Diffstat (limited to 'sphinx/util/nodes.py')
-rw-r--r--sphinx/util/nodes.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py
index 944fd3ecb..22cc9d4c0 100644
--- a/sphinx/util/nodes.py
+++ b/sphinx/util/nodes.py
@@ -531,6 +531,16 @@ def make_id(env: "BuildEnvironment", document: nodes.document,
return node_id
+def find_pending_xref_condition(node: addnodes.pending_xref, condition: str) -> Element:
+ """Pick matched pending_xref_condition node up from the pending_xref."""
+ for subnode in node:
+ if (isinstance(subnode, addnodes.pending_xref_condition) and
+ subnode.get('condition') == condition):
+ return subnode
+ else:
+ return None
+
+
def make_refnode(builder: "Builder", fromdocname: str, todocname: str, targetid: str,
child: Node, title: str = None) -> nodes.reference:
"""Shortcut to create a reference node."""