Skip to content

Commit eb98a47

Browse files
authored
Clean up autosummary usage (#54457)
* Disable numpydoc and use autosummary instead * Add toctree for accessors
1 parent d5a5a4d commit eb98a47

File tree

3 files changed

+40
-43
lines changed

3 files changed

+40
-43
lines changed

doc/_templates/autosummary/class.rst

+25-26
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
1-
{% extends "!autosummary/class.rst" %}
1+
{{ fullname | escape | underline}}
22

3-
{% block methods %}
4-
{% if methods %}
3+
.. currentmodule:: {{ module }}
54

6-
..
7-
HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages.
8-
.. autosummary::
9-
:toctree:
10-
{% for item in all_methods %}
11-
{%- if not item.startswith('_') or item in ['__call__'] %}
12-
{{ name }}.{{ item }}
13-
{%- endif -%}
14-
{%- endfor %}
5+
.. autoclass:: {{ objname }}
156

16-
{% endif %}
17-
{% endblock %}
7+
{% block methods %}
188

19-
{% block attributes %}
20-
{% if attributes %}
9+
{% block attributes %}
10+
{% if attributes %}
11+
.. rubric:: {{ _('Attributes') }}
2112

22-
..
23-
HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages.
2413
.. autosummary::
25-
:toctree:
26-
{% for item in all_attributes %}
27-
{%- if not item.startswith('_') %}
28-
{{ name }}.{{ item }}
29-
{%- endif -%}
30-
{%- endfor %}
14+
{% for item in attributes %}
15+
{% if item in members and not item.startswith('_') %}
16+
~{{ name }}.{{ item }}
17+
{% endif %}
18+
{%- endfor %}
19+
{% endif %}
20+
{% endblock %}
21+
22+
{% if methods %}
23+
.. rubric:: {{ _('Methods') }}
3124

32-
{% endif %}
33-
{% endblock %}
25+
.. autosummary::
26+
{% for item in methods %}
27+
{% if item in members and (not item.startswith('_') or item in ['__call__']) %}
28+
~{{ name }}.{{ item }}
29+
{% endif %}
30+
{%- endfor %}
31+
{% endif %}
32+
{% endblock %}

doc/source/conf.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
# to ensure that include files (partial pages) aren't built, exclude them
7777
# https://github.com/sphinx-doc/sphinx/issues/1965#issuecomment-124732907
7878
"**/includes/**",
79-
"**/api/pandas.Series.dt.rst",
8079
]
8180
try:
8281
import nbconvert
@@ -130,6 +129,8 @@
130129
autodoc_typehints = "none"
131130

132131
# numpydoc
132+
numpydoc_show_class_members = False
133+
numpydoc_show_inherited_class_members = False
133134
numpydoc_attributes_as_param_list = False
134135

135136
# matplotlib plot directive

doc/source/reference/series.rst

+13-16
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,19 @@ pandas provides dtype-specific methods under various accessors.
273273
These are separate namespaces within :class:`Series` that only apply
274274
to specific data types.
275275

276+
.. autosummary::
277+
:toctree: api/
278+
:nosignatures:
279+
:template: autosummary/accessor.rst
280+
281+
Series.str
282+
Series.cat
283+
Series.dt
284+
Series.sparse
285+
DataFrame.sparse
286+
Index.str
287+
288+
276289
=========================== =================================
277290
Data Type Accessor
278291
=========================== =================================
@@ -458,22 +471,6 @@ strings and apply several methods to it. These can be accessed like
458471
Series.str.isdecimal
459472
Series.str.get_dummies
460473

461-
..
462-
The following is needed to ensure the generated pages are created with the
463-
correct template (otherwise they would be created in the Series/Index class page)
464-
465-
..
466-
.. autosummary::
467-
:toctree: api/
468-
:template: autosummary/accessor.rst
469-
470-
Series.str
471-
Series.cat
472-
Series.dt
473-
Series.sparse
474-
DataFrame.sparse
475-
Index.str
476-
477474
.. _api.series.cat:
478475

479476
Categorical accessor

0 commit comments

Comments
 (0)