Fix #3000: `option` directive generates invalid HTML anchors

fix
This commit is contained in:
Takeshi KOMIYA 2016-10-07 12:09:50 +09:00
parent 0875507497
commit 4c3c128e9b
4 changed files with 11 additions and 8 deletions

View File

@ -22,6 +22,7 @@ Bugs fixed
if linkcheck_anchors enabled
* #3004: Invalid link types "top" and "up" are used
* #3009: Bad rendering of parsed-literals in LaTeX since Sphinx 1.4.4
* #3000: ``option`` directive generates invalid HTML anchors
Documentation
-------------

View File

@ -174,16 +174,18 @@ class Cmdoption(ObjectDescription):
if currprogram:
targetname = '-' + currprogram + targetname
targetname = 'cmdoption' + targetname
signode['ids'].append(targetname)
self.state.document.note_explicit_target(signode)
signode['names'].append(targetname)
self.state.document.note_explicit_target(signode)
for optname in signode.get('allnames', []):
self.env.domaindata['std']['progoptions'][currprogram, optname] = \
self.env.docname, targetname
self.env.docname, signode['ids'][0]
# create only one index entry for the whole option
if optname == firstname:
self.indexnode['entries'].append(
('pair', _('%scommand line option; %s') %
((currprogram and currprogram + ' ' or ''), sig),
targetname, '', None))
signode['ids'][0], '', None))
class Program(Directive):

View File

@ -240,11 +240,11 @@ HTML_XPATH = {
(".//td[@class='field-body']/ul/li/em", '^DuplicateType$'),
(".//td[@class='field-body']/ul/li/em", tail_check(r'.* Some parameter')),
# others
(".//a[@class='reference internal'][@href='#cmdoption-perl-arg-+p']/code/span",
(".//a[@class='reference internal'][@href='#cmdoption-perl-arg-p']/code/span",
'perl'),
(".//a[@class='reference internal'][@href='#cmdoption-perl-arg-+p']/code/span",
(".//a[@class='reference internal'][@href='#cmdoption-perl-arg-p']/code/span",
'\+p'),
(".//a[@class='reference internal'][@href='#cmdoption-perl--plugin.option']/code/span",
(".//a[@class='reference internal'][@href='#cmdoption-perl-plugin-option']/code/span",
'--plugin.option'),
(".//a[@class='reference internal'][@href='#cmdoption-perl-arg-create-auth-token']"
"/code/span",

View File

@ -631,7 +631,7 @@ def test_xml_builder(app, status, warning):
yield (assert_elem,
para2[3],
['LINK TO', '--module', 'AND', '-m', '.'],
['cmdoption--module', 'cmdoption-m'])
['cmdoption-module', 'cmdoption-m'])
yield (assert_elem,
para2[4],
['LINK TO', 'env2', 'AND', 'env1', '.'],