Skip to content

Transdoc Python Handler

pip install transdoc[python]

A handler for docstrings within Python. Python code is kept as-is, with only triple-quote strings being modified.

# Input
def example():
    """
    An example function.

    {{my_rule}}
    """
# Output
def example():
    """
    An example function.

    This text was added by Transdoc!
    """

If the Python file contains syntax which cannot be parsed (by libcst), a warning will be emitted, and the file will be transformed as plaintext.