Skip to content

Commit 40580ac

Browse files
committed
Don't process alternative text in deprecation
to convert rst to plain text for warnings. This reverts the rst text processing of commmit "Include alternatives to deprecations in the documentation" as it was considered to be too complex to maintain or potentially error prone.
1 parent 8ab73cd commit 40580ac

File tree

3 files changed

+1
-11
lines changed

3 files changed

+1
-11
lines changed

doc/devel/contributing.rst

+1-3
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,7 @@ Introducing
326326
All these helpers take a first parameter *since*, which should be set to
327327
the next point release, e.g. "3.x".
328328

329-
You can use standard rst cross references in the alternative. The string
330-
will be processed to remove back ticks and only include the link caption
331-
in the runtime warning.
329+
You can use standard rst cross references in *alternative*.
332330

333331
Expiring
334332
~~~~~~~~

lib/matplotlib/_api/deprecation.py

-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import functools
1515
import inspect
1616
import math
17-
import re
1817
import warnings
1918

2019

@@ -48,10 +47,6 @@ def _generate_deprecation_warning(
4847
+ (" %(addendum)s" if addendum else ""))
4948
warning_cls = (PendingDeprecationWarning if pending
5049
else MatplotlibDeprecationWarning)
51-
# remove backticks, optional leading dot and replace reference by caption
52-
if alternative:
53-
alternative = re.sub(r"`([^`]*?) *<.*?>`|`\.?(.+?)`", r"\1\2",
54-
alternative)
5550
return warning_cls(message % dict(
5651
func=name, name=name, obj_type=obj_type, since=since, removal=removal,
5752
alternative=alternative, addendum=addendum))

lib/matplotlib/tests/test_api.py

-3
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,3 @@ def test_deprecation_alternative():
9393
def f():
9494
pass
9595
assert alternative in f.__doc__
96-
with pytest.warns(_api.MatplotlibDeprecationWarning,
97-
match=r".* f1, f2, f3\(x\) or f4\(x\)"):
98-
f()

0 commit comments

Comments
 (0)