From 95510a2f5e878de04819b3ff3ef28857dca91e92 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Thu, 2 May 2013 10:37:12 +0900 Subject: Fix: Citation target missing cause AssertionError. Closes #1160 --- CHANGES | 1 + sphinx/environment.py | 4 ++++ tests/root/footnote.txt | 6 ++++++ tests/test_build_html.py | 1 + tests/test_build_latex.py | 1 + tests/test_build_texinfo.py | 1 + 6 files changed, 14 insertions(+) diff --git a/CHANGES b/CHANGES index 08493a85..ac8a9ce3 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,7 @@ Features added Bugs fixed ---------- +* #1160: Citation target missing cause AssertionError. * #1157: Combination of 'globaltoc.html' and hidden toctree cause exception. * Fix: 'make gettext' cause UnicodeDecodeError when templates contain utf-8 encoded string. diff --git a/sphinx/environment.py b/sphinx/environment.py index b27cbfed..35799bea 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -1354,6 +1354,10 @@ class BuildEnvironment: if not isinstance(contnode, nodes.Element): del node['ids'][:] raise + elif 'ids' in node: + # remove ids attribute that annotated at + # transforms.CitationReference.apply. + del node['ids'][:] # no new node found? try the missing-reference event if newnode is None: newnode = builder.app.emit_firstresult( diff --git a/tests/root/footnote.txt b/tests/root/footnote.txt index c1359dfe..b600697f 100644 --- a/tests/root/footnote.txt +++ b/tests/root/footnote.txt @@ -38,3 +38,9 @@ footenotes .. rubric:: Citations .. [bar] cite + + +missing target +-------------------- +[missing]_ citation + diff --git a/tests/test_build_html.py b/tests/test_build_html.py index 6b4a07df..73a4e309 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -49,6 +49,7 @@ http://sphinx-doc.org/domains.html HTML_WARNINGS = ENV_WARNINGS + """\ %(root)s/images.txt:20: WARNING: no matching candidate for image URI u'foo.\\*' +None:\\d+: WARNING: citation not found: missing %(root)s/markup.txt:: WARNING: invalid single index entry u'' %(root)s/markup.txt:: WARNING: invalid pair index entry u'' %(root)s/markup.txt:: WARNING: invalid pair index entry u'keyword; ' diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index bb79e52c..50aef045 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -28,6 +28,7 @@ def teardown_module(): latex_warnfile = StringIO() LATEX_WARNINGS = ENV_WARNINGS + """\ +None:None: WARNING: citation not found: missing None:None: WARNING: no matching candidate for image URI u'foo.\\*' WARNING: invalid pair index entry u'' WARNING: invalid pair index entry u'keyword; ' diff --git a/tests/test_build_texinfo.py b/tests/test_build_texinfo.py index 587d123b..eb60fb8f 100644 --- a/tests/test_build_texinfo.py +++ b/tests/test_build_texinfo.py @@ -28,6 +28,7 @@ def teardown_module(): texinfo_warnfile = StringIO() TEXINFO_WARNINGS = ENV_WARNINGS + """\ +None:None: WARNING: citation not found: missing None:None: WARNING: no matching candidate for image URI u'foo.\\*' None:None: WARNING: no matching candidate for image URI u'svgimg.\\*' """ -- cgit v1.2.1