mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
In case of wrong option, warn the right reason.
For instance, in case of `:options: +SKIPO` the message was "missing '+' or '-' in +SKIPO option`. Now it will be "SKIPO is not a valid option."
This commit is contained in:
parent
840f152c93
commit
b52118290f
@ -126,12 +126,17 @@ class TestDirective(Directive):
|
||||
# parse doctest-like output comparison flags
|
||||
option_strings = self.options['options'].replace(',', ' ').split()
|
||||
for option in option_strings:
|
||||
if (option[0] not in '+-' or option[1:] not in
|
||||
doctest.OPTIONFLAGS_BY_NAME): # type: ignore
|
||||
on_or_off, option_name = option[0], option[1:]
|
||||
if on_or_off not in '+-': # type: ignore
|
||||
self.state.document.reporter.warning(
|
||||
"missing '+' or '-' in '%s' option." % option,
|
||||
line=self.lineno)
|
||||
continue
|
||||
if option_name not in doctest.OPTIONFLAGS_BY_NAME: # type: ignore
|
||||
self.state.document.reporter.warning(
|
||||
"'%s' is not a valid option." % option_name,
|
||||
line=self.lineno)
|
||||
continue
|
||||
flag = doctest.OPTIONFLAGS_BY_NAME[option[1:]] # type: ignore
|
||||
node['options'][flag] = (option[0] == '+')
|
||||
if self.name == 'doctest' and 'pyversion' in self.options:
|
||||
|
Loading…
Reference in New Issue
Block a user