Minor Version:
This project helps to set the doc string.
The instances of dataclass function as decorators
that set the docstring of the decorated to the value of doc.
Usage:
from typing import *
from setdoc import SetDoc
# Create a setdoc instance with the desired docstring
doc_updater: SetDoc
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.
This magic method implements calling the current instance.
It sets target.__doc__
to doc.
The value that is used for __doc__.
Added in version 1.1.
Added in version 1.2.
This module variable
is alias for
SetDoc
included for legacy.