From 2574cd21d154c87f9ddba475877edc1c74655308 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Thu, 2 Mar 2023 06:26:04 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20FIX=20NoURI=20in=20doc=20referen?= =?UTF-8?q?ce=20resolutuion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- myst_parser/sphinx_ext/myst_refs.py | 9 ++++++--- tests/test_sphinx/sourcedirs/texi_table/index.md | 3 --- .../sourcedirs/{texi_table => texinfo}/conf.py | 0 tests/test_sphinx/sourcedirs/texinfo/file.md | 3 +++ tests/test_sphinx/sourcedirs/texinfo/index.md | 9 +++++++++ tests/test_sphinx/test_sphinx_builds.py | 10 +++------- 6 files changed, 21 insertions(+), 13 deletions(-) delete mode 100644 tests/test_sphinx/sourcedirs/texi_table/index.md rename tests/test_sphinx/sourcedirs/{texi_table => texinfo}/conf.py (100%) create mode 100644 tests/test_sphinx/sourcedirs/texinfo/file.md create mode 100644 tests/test_sphinx/sourcedirs/texinfo/index.md diff --git a/myst_parser/sphinx_ext/myst_refs.py b/myst_parser/sphinx_ext/myst_refs.py index 8a4dc202..74edcb37 100644 --- a/myst_parser/sphinx_ext/myst_refs.py +++ b/myst_parser/sphinx_ext/myst_refs.py @@ -178,9 +178,12 @@ def resolve_myst_ref_doc(self, node: pending_xref): ) assert self.app.builder - ref_node = make_refnode( - self.app.builder, from_docname, ref_docname, targetid, innernode - ) + try: + ref_node = make_refnode( + self.app.builder, from_docname, ref_docname, targetid, innernode + ) + except NoUri: + ref_node = innernode node.replace_self(ref_node) def resolve_myst_ref_any( diff --git a/tests/test_sphinx/sourcedirs/texi_table/index.md b/tests/test_sphinx/sourcedirs/texi_table/index.md deleted file mode 100644 index 9face4b5..00000000 --- a/tests/test_sphinx/sourcedirs/texi_table/index.md +++ /dev/null @@ -1,3 +0,0 @@ -| foo | bar | -| --- | --- | -| baz | bim | diff --git a/tests/test_sphinx/sourcedirs/texi_table/conf.py b/tests/test_sphinx/sourcedirs/texinfo/conf.py similarity index 100% rename from tests/test_sphinx/sourcedirs/texi_table/conf.py rename to tests/test_sphinx/sourcedirs/texinfo/conf.py diff --git a/tests/test_sphinx/sourcedirs/texinfo/file.md b/tests/test_sphinx/sourcedirs/texinfo/file.md new file mode 100644 index 00000000..eeea438d --- /dev/null +++ b/tests/test_sphinx/sourcedirs/texinfo/file.md @@ -0,0 +1,3 @@ +--- +orphan: true +--- diff --git a/tests/test_sphinx/sourcedirs/texinfo/index.md b/tests/test_sphinx/sourcedirs/texinfo/index.md new file mode 100644 index 00000000..c0f15f92 --- /dev/null +++ b/tests/test_sphinx/sourcedirs/texinfo/index.md @@ -0,0 +1,9 @@ +Check that NoURIError is handled correctly: + +[](file.md) + +Check that tables can be built: + +| foo | bar | +| --- | --- | +| baz | bim | diff --git a/tests/test_sphinx/test_sphinx_builds.py b/tests/test_sphinx/test_sphinx_builds.py index b5b9acc6..a41e96b8 100644 --- a/tests/test_sphinx/test_sphinx_builds.py +++ b/tests/test_sphinx/test_sphinx_builds.py @@ -564,15 +564,11 @@ def test_fieldlist_extension( @pytest.mark.sphinx( buildername="texinfo", - srcdir=os.path.join(SOURCE_DIR, "texi_table"), + srcdir=os.path.join(SOURCE_DIR, "texinfo"), freshenv=True, ) -def test_texinfo_table( - app, - status, - warning, -): - """Test that tables can be built with the Texinfo builder.""" +def test_texinfo(app, status, warning): + """Test Texinfo builds.""" app.build() assert "build succeeded" in status.getvalue() # Build succeeded warnings = warning.getvalue().strip()