From 15ec3461691857b1929c16640cb50b987dcacaf7 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 17 Aug 2023 11:16:47 -0700 Subject: [PATCH 1/2] Disable numpydoc and use autosummary instead --- doc/_templates/autosummary/class.rst | 51 ++++++++++++++-------------- doc/source/conf.py | 2 ++ 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/doc/_templates/autosummary/class.rst b/doc/_templates/autosummary/class.rst index a9c9bd2b6507f..79c2e37b0192f 100644 --- a/doc/_templates/autosummary/class.rst +++ b/doc/_templates/autosummary/class.rst @@ -1,33 +1,32 @@ -{% extends "!autosummary/class.rst" %} +{{ fullname | escape | underline}} -{% block methods %} -{% if methods %} +.. currentmodule:: {{ module }} -.. - HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages. - .. autosummary:: - :toctree: - {% for item in all_methods %} - {%- if not item.startswith('_') or item in ['__call__'] %} - {{ name }}.{{ item }} - {%- endif -%} - {%- endfor %} +.. autoclass:: {{ objname }} -{% endif %} -{% endblock %} + {% block methods %} -{% block attributes %} -{% if attributes %} + {% block attributes %} + {% if attributes %} + .. rubric:: {{ _('Attributes') }} -.. - HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages. .. autosummary:: - :toctree: - {% for item in all_attributes %} - {%- if not item.startswith('_') %} - {{ name }}.{{ item }} - {%- endif -%} - {%- endfor %} + {% for item in attributes %} + {% if item in members and not item.startswith('_') %} + ~{{ name }}.{{ item }} + {% endif %} + {%- endfor %} + {% endif %} + {% endblock %} + + {% if methods %} + .. rubric:: {{ _('Methods') }} -{% endif %} -{% endblock %} + .. autosummary:: + {% for item in methods %} + {% if item in members and (not item.startswith('_') or item in ['__call__']) %} + ~{{ name }}.{{ item }} + {% endif %} + {%- endfor %} + {% endif %} + {% endblock %} diff --git a/doc/source/conf.py b/doc/source/conf.py index 7309dc82c970b..937ef9884c857 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -130,6 +130,8 @@ autodoc_typehints = "none" # numpydoc +numpydoc_show_class_members = False +numpydoc_show_inherited_class_members = False numpydoc_attributes_as_param_list = False # matplotlib plot directive From 33f78a04510c00bd4abc7cac4a8110c569e71939 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 17 Aug 2023 11:08:11 -0700 Subject: [PATCH 2/2] Add toctree for accessors --- doc/source/conf.py | 1 - doc/source/reference/series.rst | 29 +++++++++++++---------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 937ef9884c857..accbff596b12d 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -76,7 +76,6 @@ # to ensure that include files (partial pages) aren't built, exclude them # https://github.com/sphinx-doc/sphinx/issues/1965#issuecomment-124732907 "**/includes/**", - "**/api/pandas.Series.dt.rst", ] try: import nbconvert diff --git a/doc/source/reference/series.rst b/doc/source/reference/series.rst index 41705620d4bc7..58351bab07b22 100644 --- a/doc/source/reference/series.rst +++ b/doc/source/reference/series.rst @@ -273,6 +273,19 @@ pandas provides dtype-specific methods under various accessors. These are separate namespaces within :class:`Series` that only apply to specific data types. +.. autosummary:: + :toctree: api/ + :nosignatures: + :template: autosummary/accessor.rst + + Series.str + Series.cat + Series.dt + Series.sparse + DataFrame.sparse + Index.str + + =========================== ================================= Data Type Accessor =========================== ================================= @@ -458,22 +471,6 @@ strings and apply several methods to it. These can be accessed like Series.str.isdecimal Series.str.get_dummies -.. - The following is needed to ensure the generated pages are created with the - correct template (otherwise they would be created in the Series/Index class page) - -.. - .. autosummary:: - :toctree: api/ - :template: autosummary/accessor.rst - - Series.str - Series.cat - Series.dt - Series.sparse - DataFrame.sparse - Index.str - .. _api.series.cat: Categorical accessor