Skip to content
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

Merged
merged 1 commit into from
Apr 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import re
import inspect
import importlib
from sphinx.ext.autosummary import _import_by_name
import warnings


Expand Down Expand Up @@ -47,6 +48,10 @@

])

# numpydoc is available in the sphinxext directory, and can't be imported
# until sphinxext is available in the Python path
from numpydoc.docscrape import NumpyDocString

# -- General configuration -----------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
Expand Down Expand Up @@ -505,9 +510,27 @@ def _replace_pandas_items(self, display_name, sig, summary, real_name):
summary = 'Series plotting accessor and method'
return (display_name, sig, summary, real_name)

@staticmethod
def _is_deprecated(real_name):
try:
obj, parent, modname = _import_by_name(real_name)
except ImportError:
return False
doc = NumpyDocString(obj.__doc__ or '')
summary = ''.join(doc['Summary'] + doc['Extended Summary'])
return '.. deprecated::' in summary

def _add_deprecation_prefixes(self, items):
for item in items:
display_name, sig, summary, real_name = item
if self._is_deprecated(real_name):
summary = '(DEPRECATED) %s' % summary
yield display_name, sig, summary, real_name

def get_items(self, names):
items = Autosummary.get_items(self, names)
items = [self._replace_pandas_items(*item) for item in items]
items = list(self._add_deprecation_prefixes(items))
return items


Expand Down