setdoc

Minor Version:

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.

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.
__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.basic(value: Any) -> Any

Added in version 1.1.

setdoc.getbasicdoc(name: str) -> str

Added in version 1.2.

setdoc.setdoc = setdoc.SetDoc

This module variable is alias for SetDoc included for legacy.

setdoc.test() -> unittest.TextTestResult
License
Impressum