Skip to main content

Support for documenting accessors with mkdocstrings.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocstrings_python_accessors-0.1.2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkdocstrings_python_accessors-0.1.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file mkdocstrings_python_accessors-0.1.2.tar.gz.

File metadata

File hashes

Hashes for mkdocstrings_python_accessors-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5d00d04fe16d2b71f0f0b6c70fb6a9053389e75cdacd313494e574fc702eb964
MD5 1c02477fa19e39470919723243c80661
BLAKE2b-256 eb96581e46a4c732f62d81cd5632ec9ee1dcc7ed8543fdc09be01a9a9e8eb277

See more details on using hashes here.

File details

Details for the file mkdocstrings_python_accessors-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocstrings_python_accessors-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7136fd0a84d07f9148569f6cb78a432b6d3ebbe10096687b8ce26a632d848abe
MD5 3a6508ad8bd0ef82d65b92a8baef001e
BLAKE2b-256 e80312c701405b6a27a352222f70cf812828be6bdf832a8fb52d082b95ed3404

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page