mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
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.
This commit is contained in:
@@ -859,3 +859,11 @@ def test_noindexentry(app):
|
||||
assert_node(doctree, (addnodes.index, desc, addnodes.index, desc))
|
||||
assert_node(doctree[0], addnodes.index, entries=[('single', 'f (built-in class)', 'f', '', None)])
|
||||
assert_node(doctree[2], addnodes.index, entries=[])
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='domain-py-xref-warning')
|
||||
def test_warn_missing_reference(app, status, warning):
|
||||
app.build()
|
||||
assert 'index.rst:6: WARNING: undefined label: no-label' in warning.getvalue()
|
||||
assert ('index.rst:6: WARNING: Failed to create a cross reference. A title or caption not found: existing-label'
|
||||
in warning.getvalue())
|
||||
|
||||
Reference in New Issue
Block a user