-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #9240: Unknown node error for pending_xref_condition is raised
Unknown node error for pending_xref_condition is raised if an extension that does not support the node installs a missing-reference handler.
- Loading branch information
Showing
5 changed files
with
85 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/roots/test-transforms-post_transforms-missing-reference/conf.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nitpicky = True |
5 changes: 5 additions & 0 deletions
5
tests/roots/test-transforms-post_transforms-missing-reference/index.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
transforms-post_transforms-missing-reference | ||
============================================ | ||
|
||
:class:`io.StringIO` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
""" | ||
test_transforms_post_transforms | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
Tests the post_transforms | ||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. | ||
:license: BSD, see LICENSE for details. | ||
""" | ||
|
||
import pytest | ||
from docutils import nodes | ||
|
||
|
||
@pytest.mark.sphinx('html', testroot='transforms-post_transforms-missing-reference') | ||
def test_nitpicky_warning(app, status, warning): | ||
app.build() | ||
assert ('index.rst:4: WARNING: py:class reference target ' | ||
'not found: io.StringIO' in warning.getvalue()) | ||
|
||
content = (app.outdir / 'index.html').read_text() | ||
assert ('<p><code class="xref py py-class docutils literal notranslate"><span class="pre">' | ||
'io.StringIO</span></code></p>' in content) | ||
|
||
|
||
@pytest.mark.sphinx('html', testroot='transforms-post_transforms-missing-reference', | ||
freshenv=True) | ||
def test_missing_reference(app, status, warning): | ||
def missing_reference(app, env, node, contnode): | ||
assert app is app | ||
assert env is app.env | ||
assert node['reftarget'] == 'io.StringIO' | ||
assert contnode.astext() == 'io.StringIO' | ||
|
||
return nodes.inline('', 'missing-reference.StringIO') | ||
|
||
warning.truncate(0) | ||
app.connect('missing-reference', missing_reference) | ||
app.build() | ||
assert warning.getvalue() == '' | ||
|
||
content = (app.outdir / 'index.html').read_text() | ||
assert '<p><span>missing-reference.StringIO</span></p>' in content | ||
|
||
|
||
@pytest.mark.sphinx('html', testroot='domain-py-python_use_unqualified_type_names', | ||
freshenv=True) | ||
def test_missing_reference_conditional_pending_xref(app, status, warning): | ||
def missing_reference(app, env, node, contnode): | ||
return contnode | ||
|
||
warning.truncate(0) | ||
app.connect('missing-reference', missing_reference) | ||
app.build() | ||
assert warning.getvalue() == '' | ||
|
||
content = (app.outdir / 'index.html').read_text() | ||
assert '<span class="n"><span class="pre">Age</span></span>' in content |