Skip to content

Commit

Permalink
Do not put option part after = to Index.
Browse files Browse the repository at this point in the history
  • Loading branch information
marxin committed Jan 2, 2022
1 parent eed0730 commit 6ab9ea3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sphinx/domains/std.py
Expand Up @@ -244,6 +244,8 @@ def add_target_and_index(self, firstname: str, sig: str, signode: desc_signature
else:
descr = _('command line option')
for option in sig.split(', '):
# remove trailing part followed by equal symbol
option = option.split('=')[0]
entry = '; '.join([descr, option])
self.indexnode['entries'].append(('pair', entry, signode['ids'][0], '', None))

Expand Down
12 changes: 12 additions & 0 deletions tests/test_domain_std.py
Expand Up @@ -341,6 +341,18 @@ def test_cmdoption_for_None(app):
assert domain.progoptions[(None, '-l')] == ('index', 'cmdoption-l')


def test_option_with_equal_sign(app):
text = (".. option:: -foo=bar|baz\n"
"\n"
".. option:: -l=TYPE\n")
domain = app.env.get_domain('std')
doctree = restructuredtext.parse(app, text)
assert_node(doctree[0], addnodes.index,
entries=[('pair', 'command line option; -foo', 'cmdoption-foo', '', None)])
assert_node(doctree[2], addnodes.index,
entries=[('pair', 'command line option; -l', 'cmdoption-l', '', None)])


def test_multiple_cmdoptions(app):
text = (".. program:: cmd\n"
"\n"
Expand Down

0 comments on commit 6ab9ea3

Please sign in to comment.