Skip to main content

docshare

tests docs PyPI Python versions

Share documentation between related Python objects, without repeating yourself and without templating.

Read the documentation

What it does

docshare parses NumPy- and Google-style docstrings, lets a function inherit the parts it would otherwise duplicate, and writes the result back to __doc__ as ordinary documentation. Nothing downstream needs to know: help, your editor, and Sphinx all see a normal docstring.

The library is docshare; its decorator is docwrap, which wraps one object's documentation around another's.

from docshare import docwrap


def quuxatize(foo, bar=1):
    """A function that quuxizes the arguments `foo` and `bar`.

    Parameters
    ----------
    foo : float
        The foo parameter for the quux operation.
    bar : float, optional
        The bar parameter for the quux operation; the default is 1.
    """
    pass


@docwrap(format='numpy', inheritparams=quuxatize)
def logquuxatize(foo, bar=1, base=None):
    """Returns the log of the quux of arguments `foo` and `bar`.

    Parameters
    ----------
    base : float, optional
        The base of the log that should be used; the default is ``None``.
    """
    pass

logquuxatize now documents foo, bar and base, in signature order, and nothing in the result hints that any of it was shared.

>>> pring(logquuxatize.__doc__)
Returns the log of the quux of arguments `foo` and `bar`.

Parameters
----------
foo : float
    The foo parameter for the quux operation.
bar : float, optional
    The bar parameter for the quux operation; the default is 1.
base : float, optional
    The base of the log that should be used; the default is ``None``.

A source needs no decoration and no cooperation of any kind. It needs a docstring --- including one from a library that has never heard of docshare:

import numpy as np
from docshare import docwrap

@docwrap(format='numpy', inheritparams=(np.sum, np.log))
def total(a, axis=None, base=None):
    """Sum an array, the way we like it."""
    return np.sum(np.log(a, base=base), axis=axis)

Installation

$ pip install docshare

Python 3.10 and later. No runtime dependencies.

At a glance

  • Reads and writes both NumPy and Google style, and converts between them.
  • Understands the full numpydoc section set, and preserves sections it does not understand rather than discarding them.
  • Inherits parameters, returns, raises, attributes and the rest, from one source or several, with renaming, exclusion and per-item binding.
  • Keeps grouped declarations such as x, y : float intact.
  • Reads sections of your own, declared per call, so that a library's conventions need not become everyone's.
  • Checks documented parameters against the callable's signature.
  • Works with functions, methods, classes, properties, static methods and class methods.
  • Safe to use from several threads.

Documentation

The full documentation lives at https://noahbenson.github.io/docshare/:

The specification is the normative description the implementation is checked against, and docs/deferred.md records the edge cases that were considered and how each was settled.

Development

$ pip install -e '.[dev]'
$ pytest
$ ruff check . && ruff format --check .
$ make -C docs html

License

MIT. See LICENSE.

Metadata

Release files for docshare 0.2.1

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

Source distribution (sdist)

Source distribution for docshare 0.2.1
File Size Uploaded Provenance
docshare-0.2.1.tar.gz 133.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for docshare 0.2.1
File Interpreter ABI Platform
docshare-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 188.9 kB

Release files / docshare-0.2.1.tar.gz

Download URL docshare-0.2.1.tar.gz
Size 133.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9f22050e9da101835de9e74ab633c6a4d1c4c70caa5e42baba98a873719511af
BLAKE2b-256 checksum
How to use checksums
a0c6f2f32dcd7a646b2a34b267c90c5c07db997972e5c0a6614dc27f7ff13581
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release files / docshare-0.2.1-py3-none-any.whl

Download URL docshare-0.2.1-py3-none-any.whl
Size 55.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe1bbb483b2425e545b13a43f2fb1ca401b03d382f7beb1406d9deddd7ef12ba
BLAKE2b-256 checksum
How to use checksums
64e6c920129fa6a9132c0c6bfc9cd8ae84f8b457786bcbbb0f253fb2fceb7a0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Security for docshare 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for docshare-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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