formatSignature¶
- emlib.doctools.formatSignature(name, signature, maxwidth=70, returnNewLine=False, prefix='def')[source]¶
Format a signature to align args
This function formats a signature, possibly in multiple lines, so that arguments are aligned correctly and the text does not excede the given maxwidth
Transforms a signature like:
'(a: int, b: list[foo], c=200, ..., z=None) -> list[foo]'
into:
def func(a: int, b:list[foo], c=200, signa, b=200, ... z=None ) -> list[foo]:
- Parameters:
name (
str
) – the name of the functionsignature (
str
) – the signature, as returned viastr(inspect.signature(func))
- Return type:
str
- Returns:
the realigned signature (str)