sphinx-autosummary-accessors

sphinx autosummary extension to properly format pandas or xarray accessors


Keywords
accessors, pandas, sphinx-doc, xarray
License
MIT
Install
pip install sphinx-autosummary-accessors==2023.4.0

Documentation

sphinx-autosummary-accessors

https://github.com/xarray-contrib/sphinx-autosummary-accessors/workflows/CI/badge.svg?branch=master Documentation Status

A sphinx extension to properly document pandas or xarray accessors.

sphinx.ext.autosummary is able to create summary and object pages for objects and their methods, but it doesn't work well with accessor styled properties and methods (obj.accessor.attribute). pandas has accessor documentation built using sphinx.ext.autosummary templates, which xarray recently adopted by copying the templates and all related code.

To avoid even more duplicated code, and to make it easier for projects to document their custom accessors, this project aims to provide this functionality by way of a sphinx extension.

Most of the code was adapted from pandas.

Usage

Using it should be as simple as adding

import sphinx_autosummary_accessors

extensions = [
    ...,
    "sphinx_autosummary_accessors",
]
templates = ["_templates", ..., sphinx_autosummary_accessors.templates_path]

to your conf.py and using the appropriate template:

.. autosummary::
   :template: autosummary/accessor_method.rst

   Example.test.multiply

Documentation

For more information and examples, see the documentation.