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
|
||||
* #736: Invalid sort in pair index
|
||||
* #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
|
||||
--------
|
||||
|
@ -198,12 +198,14 @@ class Cmdoption(ObjectDescription):
|
||||
domain.add_program_option(currprogram, optname,
|
||||
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),
|
||||
signode['ids'][0], '', None))
|
||||
# create an index entry
|
||||
if currprogram:
|
||||
descr = _('%s command line option') % currprogram
|
||||
else:
|
||||
descr = _('command line option')
|
||||
for option in sig.split(', '):
|
||||
entry = '; '.join([descr, option])
|
||||
self.indexnode['entries'].append(('pair', entry, signode['ids'][0], '', None))
|
||||
|
||||
|
||||
class Program(SphinxDirective):
|
||||
|
@ -261,22 +261,24 @@ def test_cmdoption(app):
|
||||
|
||||
|
||||
def test_multiple_cmdoptions(app):
|
||||
text = (".. program:: ls\n"
|
||||
text = (".. program:: cmd\n"
|
||||
"\n"
|
||||
".. option:: -h, --help\n")
|
||||
".. option:: -o directory, --output directory\n")
|
||||
domain = app.env.get_domain('std')
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(doctree, (addnodes.index,
|
||||
[desc, ([desc_signature, ([desc_name, "-h"],
|
||||
[desc_addname, ()],
|
||||
[desc, ([desc_signature, ([desc_name, "-o"],
|
||||
[desc_addname, " directory"],
|
||||
[desc_addname, ", "],
|
||||
[desc_name, "--help"],
|
||||
[desc_addname, ()])],
|
||||
[desc_name, "--output"],
|
||||
[desc_addname, " directory"])],
|
||||
[desc_content, ()])]))
|
||||
assert_node(doctree[0], addnodes.index,
|
||||
entries=[('pair', 'ls command line option; -h, --help',
|
||||
'cmdoption-ls-h', '', None)])
|
||||
assert ('ls', '-h') in domain.progoptions
|
||||
assert ('ls', '--help') in domain.progoptions
|
||||
assert domain.progoptions[('ls', '-h')] == ('index', 'cmdoption-ls-h')
|
||||
assert domain.progoptions[('ls', '--help')] == ('index', 'cmdoption-ls-h')
|
||||
entries=[('pair', 'cmd command line option; -o directory',
|
||||
'cmdoption-cmd-o', '', None),
|
||||
('pair', 'cmd command line option; --output directory',
|
||||
'cmdoption-cmd-o', '', None)])
|
||||
assert ('cmd', '-o') in domain.progoptions
|
||||
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