bpo-40798: Generate a different message for already removed elements (GH-20483)

This commit is contained in:
Florian Dahlitz 2020-05-30 09:47:32 +02:00 committed by GitHub
parent 4649202ea7
commit 735d902b36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -311,7 +311,8 @@ class DeprecatedRemoved(Directive):
final_argument_whitespace = True
option_spec = {}
_label = 'Deprecated since version {deprecated}, will be removed in version {removed}'
_deprecated_label = 'Deprecated since version {deprecated}, will be removed in version {removed}'
_removed_label = 'Deprecated since version {deprecated}, removed in version {removed}'
def run(self):
node = addnodes.versionmodified()
@ -319,7 +320,15 @@ class DeprecatedRemoved(Directive):
node['type'] = 'deprecated-removed'
version = (self.arguments[0], self.arguments[1])
node['version'] = version
label = translators['sphinx'].gettext(self._label)
env = self.state.document.settings.env
current_version = tuple(int(e) for e in env.config.version.split('.'))
removed_version = tuple(int(e) for e in self.arguments[1].split('.'))
if current_version < removed_version:
label = self._deprecated_label
else:
label = self._removed_label
label = translators['sphinx'].gettext(label)
text = label.format(deprecated=self.arguments[0], removed=self.arguments[1])
if len(self.arguments) == 3:
inodes, messages = self.state.inline_text(self.arguments[2],

View File

@ -5,3 +5,4 @@ In extensions/pyspecific.py:
{% trans %}CPython implementation detail:{% endtrans %}
{% trans %}Deprecated since version {deprecated}, will be removed in version {removed}{% endtrans %}
{% trans %}Deprecated since version {deprecated}, removed in version {removed}{% endtrans %}