Skip to main content

DocSplice

Docstring splicing for python functions 🧬

This project allows you to splice docstrings for python functions in a convenient way using a functional decorator. This enables you to more easily create consistent documentation for your API without needing to duplicate docstring sections for functions that have the same parameter descriptions or other related content. This will ease the maintenance burden for your package documentation since the content of your function or class documentation reside in a single location in the source code, instead of being duplicated within each function body.

Install

pip install docsplice

Use

Pulling parameters from multiple sources

import docsplice as doc


def fun1(a):
    """
    Do something with a number.

    Parameters
    ----------
    a : int
        The number.
    """
    
def fun2(b=0):
    """
    Another function that does something with an integer.
    
    Parameters
    ----------
    b : int, optional
        Another number! By default 0.
    """

@doc.splice({'Parameters[a]': fun1,
             'Parameters[b] as n=7': fun2}) 
def combined(a, n=7):
    """
    Some profound computation. Parameter descriptions follow:
    """

The Parameters section in the docstring for combined has been created by the splice decorator. Inspecting the object in an interactive terminal reveals that the docstring has been filled:

combined??
Signature: combined(a, n=7)
Docstring:
Some profound computation. Parameter descriptions follow:

Parameters
----------
a : int
    The number.
n : int, optional
    Another number! By default 7.
Source:   
@doc.splice({'Parameters[a]': fun1,
             'Parameters[b] as n=7': fun2}) 
def combined(a, n=7):
    """
    Some profound computation. Parameter descriptions follow:
    """

Test

The test suite contains further examples of how DocSplice can be used. Testing is done with pytest:

pytest docsplice

Contribute

Contributions are welcome!

  1. Fork it!
  2. Create your feature branch
    git checkout -b feature/rad
  3. Commit your changes
    git commit -am 'Add something rad'
  4. Push to the branch
    git push origin feature/rad
  5. Create a new Pull Request

Contact

License

Metadata

Release files for docsplice 0.2.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 docsplice 0.2.0
File Size Uploaded Provenance Actions
docsplice-0.2.0.tar.gz 13.6 kB Without provenance Details for docsplice-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 22.4 kB

Release files / docsplice-0.2.0.tar.gz

Download URL docsplice-0.2.0.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8085c4f231a0374774c3c7eb76ff1caf4413dd1fee8dc6cac7fb84179ba696a4
BLAKE2b-256 checksum
How to use checksums
d1c1cbf82947abfde90c12ff68672afe6957f1512374346ffaff4244d9550e35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.10

Release files / docsplice-0.2.0-py3-none-any.whl

Download URL docsplice-0.2.0-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b478794747fa1d1eb8ca80da3fdce4bdaff3ded7e1de7a1a8ec46596b7f6cf05
BLAKE2b-256 checksum
How to use checksums
8f1bf1943c6f4e05ce7c95e4102146ab20471a5ebc48011ed6d9efbf6f2c57d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.10

Security for docsplice 0.2.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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