diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-11-15 13:44:39 +0300 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-03-05 20:01:05 +0300 |
commit | d99132680d277db8409d17195948ee1d422dca66 (patch) | |
tree | ab5ec3a2f5cabe16358d1e03f57ae419b1a7ba39 /sphinx/util | |
parent | e1130972b2ad2e57db4ebe0a6fa83e1cb76aa6a3 (diff) |
Filter pending_xref_condition node on failed resolution
Diffstat (limited to 'sphinx/util')
-rw-r--r-- | sphinx/util/nodes.py | 10 |
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.""" |