Skip to content

Commit 008005c

Browse files
committed
Fix #9981: std domain: Strip value part of the option directive from genindex
1 parent ce6803a commit 008005c

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Features added
4141
* #10055: sphinx-build: Create directories when ``-w`` option given
4242
* #9993: std domain: Allow to refer an inline target (ex. ``_`target name```)
4343
via :rst:role:`ref` role
44+
* #9981: std domain: Strip value part of the option directive from general index
4445
* #9391: texinfo: improve variable in ``samp`` role
4546
* #9578: texinfo: Add :confval:`texinfo_cross_references` to disable cross
4647
references for readability with standalone readers

sphinx/domains/std.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def add_target_and_index(self, firstname: str, sig: str, signode: desc_signature
242242
descr = _('%s command line option') % currprogram
243243
else:
244244
descr = _('command line option')
245-
for option in sig.split(', '):
245+
for option in signode.get('allnames', []):
246246
entry = '; '.join([descr, option])
247247
self.indexnode['entries'].append(('pair', entry, signode['ids'][0], '', None))
248248

tests/test_domain_std.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ def test_cmd_option_with_optional_value(app):
9797
[desc, ([desc_signature, ([desc_name, '-j'],
9898
[desc_addname, '[=N]'])],
9999
[desc_content, ()])]))
100+
assert_node(doctree[0], addnodes.index,
101+
entries=[('pair', 'command line option; -j', 'cmdoption-j', '', None)])
102+
100103
objects = list(app.env.get_domain("std").get_objects())
101104
assert ('-j', '-j', 'cmdoption', 'index', 'cmdoption-j', 1) in objects
102105

@@ -355,10 +358,8 @@ def test_multiple_cmdoptions(app):
355358
[desc_addname, " directory"])],
356359
[desc_content, ()])]))
357360
assert_node(doctree[0], addnodes.index,
358-
entries=[('pair', 'cmd command line option; -o directory',
359-
'cmdoption-cmd-o', '', None),
360-
('pair', 'cmd command line option; --output directory',
361-
'cmdoption-cmd-o', '', None)])
361+
entries=[('pair', 'cmd command line option; -o', 'cmdoption-cmd-o', '', None),
362+
('pair', 'cmd command line option; --output', 'cmdoption-cmd-o', '', None)])
362363
assert ('cmd', '-o') in domain.progoptions
363364
assert ('cmd', '--output') in domain.progoptions
364365
assert domain.progoptions[('cmd', '-o')] == ('index', 'cmdoption-cmd-o')

0 commit comments

Comments
 (0)