tantale / deprecated

Python @deprecated decorator to deprecate old python classes, functions or methods.
MIT License
298 stars 32 forks source link

Feature request: strip Sphinx syntax from sphinx.deprecated warning message #41

Closed soxofaan closed 3 years ago

soxofaan commented 3 years ago

Say you use the sphinx decorator with Sphinx syntax references like this:

from deprecated.sphinx import deprecated

@deprecated(reason="Use :py:func:`add` instead", version="1.2.3")
def add(x, y):
    return x + y

add(2,3)

the DeprecationWarning will say:

Call to deprecated function (or staticmethod) add. (Use :py:func:`add` instead) -- Deprecated since version 1.2.3.

For a normal user of my library this :py:func: looks weird. The user typically does not know/care that I use Sphinx as documentation build tool, let alone that they understand this syntax.

Feature request:

Strip this kind of Sphinx syntax from the DeprecationWarning message

tantale commented 3 years ago

Hello Stefaan,

If we use some bleach of any kind to clean up the Sphinx warning message, I'm afraid we get side effects…

A ”normal user” of your library should be a developper too, isn't it? So, he can understand weird syntax.

I must consider your request more carefully. In the meanwhile, do you have any suggestion on how to change that, with a PR?

Regards.

soxofaan commented 3 years ago

If we use some bleach of any kind to clean up the Sphinx warning message, I'm afraid we get side effects…

I would only strip :py:func: like construct, not the whole Sphinx syntax set. Can be done with a tight regex, that shouldn't cause much trouble.

I already started a PR here: #42

tantale commented 3 years ago

🐍 Deprecated v1.2.12 released 🚀!