Fix parsing of options with enabled option_emphasise_placeholders (#10565)

This commit is contained in:
Martin Liška 2022-06-19 23:51:48 +02:00 committed by GitHub
parent ec596de871
commit ea46202565
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 17 deletions

View File

@ -186,16 +186,15 @@ class Cmdoption(ObjectDescription[str]):
signode += addnodes.desc_name(optname, optname)
if self.env.config.option_emphasise_placeholders:
add_end_bracket = False
if not args:
continue
if args:
if args[0] == '[' and args[-1] == ']':
add_end_bracket = True
signode += addnodes.desc_sig_punctuation('[', '[')
args = args[1:-1]
if args[0] == ' ':
elif args[0] == ' ':
signode += addnodes.desc_sig_space()
args = args.strip()
if args[0] == '=':
elif args[0] == '=':
signode += addnodes.desc_sig_punctuation('=', '=')
args = args[1:]
for part in samp_role.parse(args):

View File

@ -1748,6 +1748,8 @@ def test_option_emphasise_placeholders(app, status, warning):
'<span class="pre">-</span>'
'<em><span class="pre">COUNT</span></em>' in content)
assert '<span class="pre">{{value}}</span>' in content
assert ('<span class="pre">--plugin.option</span></span>'
'<a class="headerlink" href="#cmdoption-perl-plugin.option" title="Permalink to this definition">¶</a></dt>') in content
@pytest.mark.sphinx('html', testroot='root')
@ -1757,6 +1759,9 @@ def test_option_emphasise_placeholders_default(app, status, warning):
assert '<span class="pre">={TYPE}</span>' in content
assert '<span class="pre">={WHERE}-{COUNT}</span></span>' in content
assert '<span class="pre">{client_name}</span>' in content
assert ('<span class="pre">--plugin.option</span></span>'
'<span class="sig-prename descclassname"></span>'
'<a class="headerlink" href="#cmdoption-perl-plugin.option" title="Permalink to this definition">¶</a></dt>') in content
@pytest.mark.sphinx('html', testroot='theming')