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

Tests : CI Coverage

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.

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.1.tar.gz (5.7 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.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for mkdocstrings_python_accessors-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3ea00463ac718ddf43e5f22c2f27477d01893fa09b9109ab52f507dba79ea9b2
MD5 eadb2283841de95f2c0b455555eb39fb
BLAKE2b-256 82ca2d3aee99c459d7b3ab55aa09b2ae71de1406c6736c858c41050d4faad481

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mkdocstrings_python_accessors-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e04b3a29cba946ea46680adfcf78b4386fffa829e9d9803e3cf6ae881aa41e8c
MD5 b30ff0e6f81f079a70ede67694cca5b8
BLAKE2b-256 7219c211d05c3f01e60ffe4aa8e77b9661560f1c30151a76cff74094fe3a8a7e

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