-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding (DEPRECATED) prefix to deprecated objects summary in the documentation #19220
Conversation
I think it wasn't clear in the description. This PR isn't finished and shouldn't be committed, it's just to show the general idea on what could be done. I'll finish if after some discussion this seems like a good approach. |
can you post a screen shot of the new version? (just a sample where we have actual deprecated showing) |
Sure @jreback , here you have: The change in this pull request only affects these autosummaries. For the detail page, with the directive it's already shown. But may be we can customize the sphinx template and make it more visible: |
on the auto summaries is it possible to just have: [(DEPRECATED) what the function does?] |
Oh, didn't see it. Yes, the idea is what you say, if you check the Does it look like a good idea then? It was a proof of concept, as @jorisvandenbossche thought that adding the DEPRECATED word manually could be simpler. If this approach sounds good, I'll finish and fix the PR (it's showing the DEPRECATED word when a parameter is deprecated but not the function/method). |
@datapythonista ok, so it was just an issue with that doc-string. that's ok then. I think if we can (and you show its straightforward) to do this autmatically then that is the best. manually doing things is always error prone. Sure we have to add the deprecated directive, but at least its only one thing we are adding. |
Didn't look in detail yet, but a simple I agree this does look like a nice and rather simple method to fix the autosummary tables (although I personally still think the more 'screaming' DEPRECATED can also be useful for plain text docstrings to users don't miss it, but I won't press on that) |
Ah, I didn't read your last comment in detail as you already mentioned that yourself! |
Yep, I was aware @jorisvandenbossche. I just pushed a version that does the right thing (just add the deprecation string if the method is deprecated, not the parameters). I reviewed Please let me know if the PR looks all right now. Thanks! |
doc/source/conf.py
Outdated
@staticmethod | ||
def _is_deprecated(real_name): | ||
from sphinx.ext.autosummary import _import_by_name | ||
from numpydoc.docscrape import NumpyDocString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can these imports go at the top?
@jreback, the numpydoc import can't be at the very top, because it requires the sphinxext directory to be in the PYTHONPATH. I moved it after the update of sys.path. |
@TomAugspurger @jorisvandenbossche ok with this? |
can you rebase happy to merge this |
Rebased, thanks! |
thanks @datapythonista have a look at the built docs to verify this looks ok |
git diff upstream/master -u -- "*.py" | flake8 --diff
In #18934, @jorisvandenbossche pointed out that replacing a "manual" DEPRECATED comment at the beginning of the docstrings by the
.. deprecated::
sphinx directive had a drawback: in the summary pages of the documentation, it doesn't show that the method is deprecated anymore.This PR shows a way (there are surely others) of using the sphinx directive to add the DEPRECATED prefix automatically.
So, for example, in a page like https://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.html, in the list of methods, if
abs
was deprecated, instead of the current text (in the right column):if would show:
Personally I think this way is cleaner than adding the DEPRECATED text to each docstring.