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.
  • 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.1.0

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.1.0
File Size Uploaded Provenance
docshare-0.1.0.tar.gz 112.6 kB With provenance Details

Built distribution (wheel)

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

Total release size: 158.9 kB

Release files / docshare-0.1.0.tar.gz

Download URL docshare-0.1.0.tar.gz
Size 112.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6dc60ab6cb71df539e5b9aa6a781a57c5e01e73a494f59635dde02e462676185
BLAKE2b-256 checksum
How to use checksums
fd5fc50813c9c0634dff38cdb40d09ee4f8355c2538b2d932826471ba4fcf6ee
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 18, 2026.

Transparency log

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

Download URL docshare-0.1.0-py3-none-any.whl
Size 46.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
860c55f8d0d55d57e0887daeec9b8ba8d928ddf92bc4d370ef3b2b8f744ffab8
BLAKE2b-256 checksum
How to use checksums
5af2d7d6f6eba05cc472de48307e6f0cc3f42207197a6722bbc7b9c655b0a0c5
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 18, 2026.

Transparency log

Security for docshare 0.1.0

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.1.0.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 18, 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