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.

>>> print(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.
  • Composes and renders documentation without decorating anything, with doccompose and docrender.
  • 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 guide describes how the library behaves, 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.3.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.3.0
File Size Uploaded Provenance
docshare-0.3.0.tar.gz 127.2 kB With provenance Details

Built distribution (wheel)

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

Total release size: 184.0 kB

Release files / docshare-0.3.0.tar.gz

Download URL docshare-0.3.0.tar.gz
Size 127.2 kB
Tags Source
SHA-256 checksum
How to use checksums
950407cea19ab81c1341583434d522a5b3741793c96773c56610a7e75a6ac510
BLAKE2b-256 checksum
How to use checksums
a6b4f361ceb9924378b8636fe5443b1cb8c48d63cba769abfa6e7cd187e4332c
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 27, 2026.

Transparency log

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

Download URL docshare-0.3.0-py3-none-any.whl
Size 56.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ace11b48d39bcf9bb221d482d95fcca672b6fafd995299ed28bde29ac09a3311
BLAKE2b-256 checksum
How to use checksums
16ab5eca1afd5436350456c43f8e432b25749ae91291c62c60c8ea2def2c5687
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 27, 2026.

Transparency log

Security for docshare 0.3.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.3.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 27, 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