Skip to main content

mkdocstrings-python-accessors

Support for documenting accessors with mkdocstrings.

Key info : Main branch: supported Python versions Licence

PyPI : PyPI

CI : CI

Other info : Last Commit Contributors

Status

  • development: the project is actively being worked on

Installation

The latest version of mkdocstrings-python-accessors can be installed with

=== "pip" sh pip install mkdocstrings-python-accessors

For developers

This package isn't maintained in our usual way. It's super thin and not subject to any of our usual tests etc. Hence there are no installation instructions here.

Usage

Python handler for mkdocstrings supporting documentation of accessors. Takes inspiration from sphinx-autosummary-accessors.

This package extends mkdocstrings-python (well, technically, mkdocstrings-python-xref) to support more desirable documentation of accessors.

The accessors pattern is normally something like the following. Let's take pandas. It is possible to register custom accessors, so you can do operations via that namespace. For example, pd.DataFrame.custom_namespace.operation(). When implemented, this is usually done via some sub-class, which is then registered with the upstream package (in this case pandas). The pattern normally looks something like the below

@pd.register_accessor("custom_namespace")
class CustomNamespaceAccessor:
    def __init__(self, pandas_obj):
        self._obj = pandas_obj

    def operation(self):
        # Normally you do a more elaborate operation than this,
        # but you get the idea.
        return self._obj * 2

When you come to document this, you normally get just the documentation for the class CustomNamespaceAccessor. For example, if you include the following in your docs.

::: CustomNamespaceAccessor
    handler: python

Then you will get documentation for CustomNamespaceAccessor.

This package introduces the following options.

::: CustomNamespaceAccessor
    handler: python_accessors
    options:
        namespace: "pd.DataFrame.custom_namespace"

With this, the documentation will be transformed. Instead of creating docs for CustomNamespaceAccessor, you will instead get docs for pd.DataFrame.custom_namespace.

The configuration we have found works best is the below, but you can use all the normal options that can be passed to mkdocstrings-python and mkdocstrings-python-xref to modify the appearance as you wish.

::: CustomNamespaceAccessor
    handler: python_accessors
    options:
        namespace: "pd.DataFrame.custom_namespace"
        show_root_full_path: false
        show_root_heading: true

Original template

This project was generated from this template: copier core python repository. copier is used to manage and distribute this template.

Metadata

Release files for mkdocstrings-python-accessors 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mkdocstrings-python-accessors 0.1.2
File Size Uploaded
mkdocstrings_python_accessors-0.1.2.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mkdocstrings-python-accessors 0.1.2
File Interpreter ABI Platform
mkdocstrings_python_accessors-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 11.6 kB

Release files / mkdocstrings_python_accessors-0.1.2.tar.gz

Download URL mkdocstrings_python_accessors-0.1.2.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5d00d04fe16d2b71f0f0b6c70fb6a9053389e75cdacd313494e574fc702eb964
BLAKE2b-256 checksum
How to use checksums
eb96581e46a4c732f62d81cd5632ec9ee1dcc7ed8543fdc09be01a9a9e8eb277
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.5.11

Release files / mkdocstrings_python_accessors-0.1.2-py3-none-any.whl

Download URL mkdocstrings_python_accessors-0.1.2-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7136fd0a84d07f9148569f6cb78a432b6d3ebbe10096687b8ce26a632d848abe
BLAKE2b-256 checksum
How to use checksums
e80312c701405b6a27a352222f70cf812828be6bdf832a8fb52d082b95ed3404
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.5.11

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page