diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-01-20 17:06:56 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-01-20 19:43:43 +0900 |
commit | 896ab3a2f5abbc5868a9346084627361d6b56f8c (patch) | |
tree | d2e122c5eadec53cc9a5e12e78129633c5d9de99 | |
parent | d3058f462de8abc514e662270d3df62b08f953f9 (diff) | |
download | sphinx-git-896ab3a2f5abbc5868a9346084627361d6b56f8c.tar.gz |
Fix #4434: pure numbers as link targets produce warning
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | sphinx/domains/std.py | 5 | ||||
-rw-r--r-- | tests/roots/test-root/markup.txt | 2 | ||||
-rw-r--r-- | tests/test_build_html.py | 2 | ||||
-rw-r--r-- | tests/test_build_html5.py | 2 | ||||
-rw-r--r-- | tests/test_build_latex.py | 8 |
6 files changed, 14 insertions, 6 deletions
@@ -20,6 +20,7 @@ Bugs fixed * #4412: Updated jQuery version from 3.1.0 to 3.2.1 * #4438: math: math with labels with whitespace cause html error * #2437: make full reference for classes, aliased with "alias of" +* #4434: pure numbers as link targets produce warning Testing -------- diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py index 68baa04aa..a26109076 100644 --- a/sphinx/domains/std.py +++ b/sphinx/domains/std.py @@ -607,8 +607,9 @@ class StandardDomain(Domain): if node.tagname == 'target' and 'refid' in node: # indirect hyperlink targets node = document.ids.get(node['refid']) labelid = node['names'][0] - if name.isdigit() or 'refuri' in node or \ - node.tagname.startswith('desc_'): + if (node.tagname == 'footnote' or + 'refuri' in node or + node.tagname.startswith('desc_')): # ignore footnote labels, labels automatically generated from a # link and object descriptions continue diff --git a/tests/roots/test-root/markup.txt b/tests/roots/test-root/markup.txt index b514b3587..e6adef55e 100644 --- a/tests/roots/test-root/markup.txt +++ b/tests/roots/test-root/markup.txt @@ -1,6 +1,7 @@ :tocdepth: 2 .. title:: set by title directive +.. _1024: Testing various markup ====================== @@ -152,6 +153,7 @@ Adding \n to test unescaping. * :ref:`my-table-name` * :ref:`my-code-block` * :ref:`my-code-block-name` +* :ref:`1024` * :numref:`my-figure` * :numref:`my-figure-name` * :numref:`my-table` diff --git a/tests/test_build_html.py b/tests/test_build_html.py index 6fc024d35..bf9cc7f14 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -270,6 +270,8 @@ def test_html_warnings(app, warning): # tests for ``any`` role (".//a[@href='#with']/span", 'headings'), (".//a[@href='objects.html#func_without_body']/code/span", 'objects'), + # tests for numeric labels + (".//a[@href='#id1'][@class='reference internal']/span", 'Testing various markup'), # tests for smartypants (".//li", u'Smart “quotes” in English ‘text’.'), (".//li", u'Smart — long and – short dashes.'), diff --git a/tests/test_build_html5.py b/tests/test_build_html5.py index 217050ec7..f489a8b2f 100644 --- a/tests/test_build_html5.py +++ b/tests/test_build_html5.py @@ -179,6 +179,8 @@ def cached_etree_parse(): # tests for ``any`` role (".//a[@href='#with']/span", 'headings'), (".//a[@href='objects.html#func_without_body']/code/span", 'objects'), + # tests for numeric labels + (".//a[@href='#id1'][@class='reference internal']/span", 'Testing various markup'), ], 'objects.html': [ (".//dt[@id='mod.Cls.meth1']", ''), diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 1ba115092..c23f50c65 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -130,24 +130,24 @@ def test_writer(app, status, warning): assert ('\\begin{sphinxfigure-in-table}\n\\centering\n\\capstart\n' '\\noindent\\sphinxincludegraphics{{img}.png}\n' - '\\sphinxfigcaption{figure in table}\\label{\\detokenize{markup:id7}}' + '\\sphinxfigcaption{figure in table}\\label{\\detokenize{markup:id8}}' '\\end{sphinxfigure-in-table}\\relax' in result) assert ('\\begin{wrapfigure}{r}{0pt}\n\\centering\n' '\\noindent\\sphinxincludegraphics{{rimg}.png}\n' - '\\caption{figure with align option}\\label{\\detokenize{markup:id8}}' + '\\caption{figure with align option}\\label{\\detokenize{markup:id9}}' '\\end{wrapfigure}' in result) assert ('\\begin{wrapfigure}{r}{0.500\\linewidth}\n\\centering\n' '\\noindent\\sphinxincludegraphics{{rimg}.png}\n' '\\caption{figure with align \\& figwidth option}' - '\\label{\\detokenize{markup:id9}}' + '\\label{\\detokenize{markup:id10}}' '\\end{wrapfigure}' in result) assert ('\\begin{wrapfigure}{r}{3cm}\n\\centering\n' '\\noindent\\sphinxincludegraphics[width=3cm]{{rimg}.png}\n' '\\caption{figure with align \\& width option}' - '\\label{\\detokenize{markup:id10}}' + '\\label{\\detokenize{markup:id11}}' '\\end{wrapfigure}' in result) |