Skip to content

Commit cf40991

Browse files
DOC: hack to numpydoc to avoid warnings for Categorical (not including members)
The Categorical docstring in api.rst uses a seperate template to not include an autosummary table with toctrees of all members. But numpydoc still includes a list by default (which will gives thousands of warnings). This hack ensures that for Categorical class docstring this list is not included.
1 parent e8339f7 commit cf40991

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

doc/sphinxext/numpydoc/docscrape_sphinx.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def __init__(self, docstring, config={}):
1919
def load_config(self, config):
2020
self.use_plots = config.get('use_plots', False)
2121
self.class_members_toctree = config.get('class_members_toctree', True)
22+
self.class_members_list = config.get('class_members_list', True)
2223

2324
# string conversion routines
2425
def _str_header(self, name, symbol='`'):
@@ -95,7 +96,7 @@ def _str_member_list(self, name):
9596
9697
"""
9798
out = []
98-
if self[name]:
99+
if self[name] and self.class_members_list:
99100
out += ['.. rubric:: %s' % name, '']
100101
prefix = getattr(self, '_name', '')
101102

doc/sphinxext/numpydoc/numpydoc.py

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ def mangle_docstrings(app, what, name, obj, options, lines,
4242
class_members_toctree=app.config.numpydoc_class_members_toctree,
4343
)
4444

45+
# PANDAS HACK (to remove the list of methods/attributes for Categorical)
46+
if what == "class" and name.endswith(".Categorical"):
47+
cfg['class_members_list'] = False
48+
4549
if what == 'module':
4650
# Strip top title
4751
title_re = re.compile(sixu('^\\s*[#*=]{4,}\\n[a-z0-9 -]+\\n[#*=]{4,}\\s*'),

0 commit comments

Comments
 (0)