diff --git a/CHANGES b/CHANGES index 70f5aeeb8..e1507cbdd 100644 --- a/CHANGES +++ b/CHANGES @@ -42,6 +42,7 @@ Features added imported members. * C++, add ``:tparam-line-spec:`` option to templated declarations. When specified, each template parameter will be rendered on a separate line. +* #3303: Add ``:pyversion:`` option to the doctest directive. Bugs fixed ---------- @@ -73,8 +74,6 @@ Deprecated Features added -------------- -* #3303: Added ``:pyversion:`` option to the doctest directive - Bugs fixed ---------- diff --git a/doc/ext/doctest.rst b/doc/ext/doctest.rst index 47331dea2..d1cb3c31d 100644 --- a/doc/ext/doctest.rst +++ b/doc/ext/doctest.rst @@ -84,7 +84,7 @@ a comma-separated list of group names. comparison is performed by `distutils.version.LooseVersion `__. - .. versionadded:: 1.5 + .. versionadded:: 1.6 Note that like with standard doctests, you have to use ```` to signal a blank line in the expected output. The ```` is removed diff --git a/sphinx/ext/doctest.py b/sphinx/ext/doctest.py index b8e24fe1a..cd6397fb1 100644 --- a/sphinx/ext/doctest.py +++ b/sphinx/ext/doctest.py @@ -31,6 +31,7 @@ from sphinx.util import force_decode, logging from sphinx.util.nodes import set_source_info from sphinx.util.console import bold # type: ignore from sphinx.util.osutil import fs_encoding +from sphinx.locale import _ if False: # For type annotation @@ -126,15 +127,15 @@ class TestDirective(Directive): # parse doctest-like output comparison flags option_strings = self.options['options'].replace(',', ' ').split() for option in option_strings: - on_or_off, option_name = option[0], option[1:] - if on_or_off not in '+-': # type: ignore + prefix, option_name = option[0], option[1:] + if prefix not in '+-': # type: ignore self.state.document.reporter.warning( - "missing '+' or '-' in '%s' option." % option, + _("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, + _("'%s' is not a valid option.") % option_name, line=self.lineno) continue flag = doctest.OPTIONFLAGS_BY_NAME[option[1:]] # type: ignore @@ -150,7 +151,7 @@ class TestDirective(Directive): node['options'][flag] = True # Skip the test except ValueError: self.state.document.reporter.warning( - "'%s' is not a valid pyversion option" % option, + _("'%s' is not a valid pyversion option") % option, line=self.lineno) return [node]