setdoc
Introduction

This project helps to set the doc string.

Installation
Features
class setdoc.SetDoc(doc: Any)

The instances of dataclass function as decorators that set the docstring of the decorated to the value of doc.

__call__(target: Any) -> Any

This magic method implements calling the current instance. It sets target.__doc__ to doc.

doc: Any

The value that is used for __doc__.

setdoc

This module variable is alias for SetDoc included for legacy.

Usage
from typing import *
from setdoc import setdoc

# Create a setdoc instance with the desired docstring
doc_updater = setdoc("This function adds two numbers.")

# Apply it to a target function
@doc_updater
def add(a: int, b: int) -> int:
    return a + b

# The function now has an updated docstring
print(add.__doc__)
# Output: This function adds two numbers.

# Apply it directly to another target function
@setdoc("This function multiplies two numbers.")
def mul(a: int, b: int) -> int:
    return a * b

# The function now has an updated docstring
print(mul.__doc__)
# Output: This function multiplies two numbers.
Testing
License
Impressum