diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-05-22 01:24:47 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-05-22 11:17:50 +0900 |
commit | d62a2747093ac371a7316e18a77ce2f64638f413 (patch) | |
tree | 24a0329863422942f54b473df90ecbd98f3b7ad1 | |
parent | 506d4c87ef88ec6df0df20d261bb2c1381646b9f (diff) | |
download | sphinx-git-d62a2747093ac371a7316e18a77ce2f64638f413.tar.gz |
Fix #4983: productionlist directive generates invalid IDs for the tokens
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | sphinx/domains/std.py | 2 | ||||
-rw-r--r-- | tests/test_build_html.py | 4 | ||||
-rw-r--r-- | tests/test_build_html5.py | 4 |
4 files changed, 7 insertions, 5 deletions
@@ -33,6 +33,7 @@ Incompatible changes :confval:`viewcode_follow_imported_members` (refs: #4035) * #1857: latex: :confval:`latex_show_pagerefs` does not add pagerefs for citations +* #4983: html: The URL for the productionlist has been changed Deprecated ---------- @@ -120,6 +121,7 @@ Bugs fixed * #4850: latex: footnote inside footnote was not rendered * #4945: i18n: fix lang_COUNTRY not fallback correctly for IndexBuilder. Thanks to Shengjing Zhu. +* #4983: productionlist directive generates invalid IDs for the tokens Testing -------- diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py index bc6b4de6c..002820ebd 100644 --- a/sphinx/domains/std.py +++ b/sphinx/domains/std.py @@ -432,7 +432,7 @@ class ProductionList(SphinxDirective): subnode = addnodes.production() subnode['tokenname'] = name.strip() if subnode['tokenname']: - idname = 'grammar-token-%s' % subnode['tokenname'] + idname = nodes.make_id('grammar-token-%s' % subnode['tokenname']) if idname not in self.state.document.ids: subnode['ids'].append(idname) self.state.document.note_implicit_target(subnode, subnode) diff --git a/tests/test_build_html.py b/tests/test_build_html.py index 2b45720d1..474d47261 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -227,7 +227,7 @@ def test_html_warnings(app, warning): "[@class='reference internal']/code/span[@class='pre']", 'HOME'), (".//a[@href='#with']" "[@class='reference internal']/code/span[@class='pre']", '^with$'), - (".//a[@href='#grammar-token-try_stmt']" + (".//a[@href='#grammar-token-try-stmt']" "[@class='reference internal']/code/span", '^statement$'), (".//a[@href='#some-label'][@class='reference internal']/span", '^here$'), (".//a[@href='#some-label'][@class='reference internal']/span", '^there$'), @@ -259,7 +259,7 @@ def test_html_warnings(app, warning): (".//dl/dt[@id='term-boson']", 'boson'), # a production list (".//pre/strong", 'try_stmt'), - (".//pre/a[@href='#grammar-token-try1_stmt']/code/span", 'try1_stmt'), + (".//pre/a[@href='#grammar-token-try1-stmt']/code/span", 'try1_stmt'), # tests for ``only`` directive (".//p", 'A global substitution.'), (".//p", 'In HTML.'), diff --git a/tests/test_build_html5.py b/tests/test_build_html5.py index 265c42cbd..82050cee1 100644 --- a/tests/test_build_html5.py +++ b/tests/test_build_html5.py @@ -135,7 +135,7 @@ def cached_etree_parse(): "[@class='reference internal']/code/span[@class='pre']", 'HOME'), (".//a[@href='#with']" "[@class='reference internal']/code/span[@class='pre']", '^with$'), - (".//a[@href='#grammar-token-try_stmt']" + (".//a[@href='#grammar-token-try-stmt']" "[@class='reference internal']/code/span", '^statement$'), (".//a[@href='#some-label'][@class='reference internal']/span", '^here$'), (".//a[@href='#some-label'][@class='reference internal']/span", '^there$'), @@ -167,7 +167,7 @@ def cached_etree_parse(): (".//dl/dt[@id='term-boson']", 'boson'), # a production list (".//pre/strong", 'try_stmt'), - (".//pre/a[@href='#grammar-token-try1_stmt']/code/span", 'try1_stmt'), + (".//pre/a[@href='#grammar-token-try1-stmt']/code/span", 'try1_stmt'), # tests for ``only`` directive (".//p", 'A global substitution.'), (".//p", 'In HTML.'), |