mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #6494 from tk0miya/5592_cmdoption_registers_multiple_indices
Close #5592: option directive registers an index entry for each comma separated option
This commit is contained in:
commit
8782e50eae
2
CHANGES
2
CHANGES
@ -51,6 +51,8 @@ Bugs fixed
|
|||||||
* #6531: Failed to load last environment object when extension added
|
* #6531: Failed to load last environment object when extension added
|
||||||
* #736: Invalid sort in pair index
|
* #736: Invalid sort in pair index
|
||||||
* #6527: :confval:`last_updated` wrongly assumes timezone as UTC
|
* #6527: :confval:`last_updated` wrongly assumes timezone as UTC
|
||||||
|
* #5592: std domain: :rst:dir:`option` directive registers an index entry for
|
||||||
|
each comma separated option
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -198,12 +198,14 @@ class Cmdoption(ObjectDescription):
|
|||||||
domain.add_program_option(currprogram, optname,
|
domain.add_program_option(currprogram, optname,
|
||||||
self.env.docname, signode['ids'][0])
|
self.env.docname, signode['ids'][0])
|
||||||
|
|
||||||
# create only one index entry for the whole option
|
# create an index entry
|
||||||
if optname == firstname:
|
if currprogram:
|
||||||
self.indexnode['entries'].append(
|
descr = _('%s command line option') % currprogram
|
||||||
('pair', _('%scommand line option; %s') %
|
else:
|
||||||
((currprogram and currprogram + ' ' or ''), sig),
|
descr = _('command line option')
|
||||||
signode['ids'][0], '', None))
|
for option in sig.split(', '):
|
||||||
|
entry = '; '.join([descr, option])
|
||||||
|
self.indexnode['entries'].append(('pair', entry, signode['ids'][0], '', None))
|
||||||
|
|
||||||
|
|
||||||
class Program(SphinxDirective):
|
class Program(SphinxDirective):
|
||||||
|
@ -261,22 +261,24 @@ def test_cmdoption(app):
|
|||||||
|
|
||||||
|
|
||||||
def test_multiple_cmdoptions(app):
|
def test_multiple_cmdoptions(app):
|
||||||
text = (".. program:: ls\n"
|
text = (".. program:: cmd\n"
|
||||||
"\n"
|
"\n"
|
||||||
".. option:: -h, --help\n")
|
".. option:: -o directory, --output directory\n")
|
||||||
domain = app.env.get_domain('std')
|
domain = app.env.get_domain('std')
|
||||||
doctree = restructuredtext.parse(app, text)
|
doctree = restructuredtext.parse(app, text)
|
||||||
assert_node(doctree, (addnodes.index,
|
assert_node(doctree, (addnodes.index,
|
||||||
[desc, ([desc_signature, ([desc_name, "-h"],
|
[desc, ([desc_signature, ([desc_name, "-o"],
|
||||||
[desc_addname, ()],
|
[desc_addname, " directory"],
|
||||||
[desc_addname, ", "],
|
[desc_addname, ", "],
|
||||||
[desc_name, "--help"],
|
[desc_name, "--output"],
|
||||||
[desc_addname, ()])],
|
[desc_addname, " directory"])],
|
||||||
[desc_content, ()])]))
|
[desc_content, ()])]))
|
||||||
assert_node(doctree[0], addnodes.index,
|
assert_node(doctree[0], addnodes.index,
|
||||||
entries=[('pair', 'ls command line option; -h, --help',
|
entries=[('pair', 'cmd command line option; -o directory',
|
||||||
'cmdoption-ls-h', '', None)])
|
'cmdoption-cmd-o', '', None),
|
||||||
assert ('ls', '-h') in domain.progoptions
|
('pair', 'cmd command line option; --output directory',
|
||||||
assert ('ls', '--help') in domain.progoptions
|
'cmdoption-cmd-o', '', None)])
|
||||||
assert domain.progoptions[('ls', '-h')] == ('index', 'cmdoption-ls-h')
|
assert ('cmd', '-o') in domain.progoptions
|
||||||
assert domain.progoptions[('ls', '--help')] == ('index', 'cmdoption-ls-h')
|
assert ('cmd', '--output') in domain.progoptions
|
||||||
|
assert domain.progoptions[('cmd', '-o')] == ('index', 'cmdoption-cmd-o')
|
||||||
|
assert domain.progoptions[('cmd', '--output')] == ('index', 'cmdoption-cmd-o')
|
||||||
|
Loading…
Reference in New Issue
Block a user