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.
This magic method implements calling the current instance.
It sets target.__doc__
to doc.
The value that is used for __doc__.
This module variable
is alias for
SetDoc
included for legacy.
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.