summaryrefslogtreecommitdiff
path: root/sphinx/transforms
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-08-08 20:06:46 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-11-03 02:27:43 +0900
commit0e98e9b1a8ade24acf1d91f59aa90e8b1e179b19 (patch)
tree6fdb9ca354e92e1fe28efb6fbf9fdabf45e77f15 /sphinx/transforms
parent487b8436c6e8dc596db4b8d4d06e9145105a2ac2 (diff)
downloadsphinx-git-0e98e9b1a8ade24acf1d91f59aa90e8b1e179b19.tar.gz
Fix #6914: Emit a detailed warning when failed to resolve :ref:
To be clear the ambiguous warning for missing-reference :ref:, this separates the warning to missing-label and missing-caption. To emit a warning dynamically, this also adds a new event: `warn-missing-reference` to customize warning messages via event handlers.
Diffstat (limited to 'sphinx/transforms')
-rw-r--r--sphinx/transforms/post_transforms/__init__.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/sphinx/transforms/post_transforms/__init__.py b/sphinx/transforms/post_transforms/__init__.py
index 7dc14af52..6633d6434 100644
--- a/sphinx/transforms/post_transforms/__init__.py
+++ b/sphinx/transforms/post_transforms/__init__.py
@@ -166,7 +166,10 @@ class ReferencesResolver(SphinxPostTransform):
warn = False
if not warn:
return
- if domain and typ in domain.dangling_warnings:
+
+ if self.app.emit_firstresult('warn-missing-reference', domain, node):
+ return
+ elif domain and typ in domain.dangling_warnings:
msg = domain.dangling_warnings[typ]
elif node.get('refdomain', 'std') not in ('', 'std'):
msg = (__('%s:%s reference target not found: %%(target)s') %