Docstrings

starstar.nestdoc(*funcs, template='{}_kw', **named)[source]

Nest a function’s docstring parameters as a dict in another function’s parameters.

Parameters:
  • *funcs – functions to nest. The argument name is gotten using template.

  • template (str) – The keyword argument template for *funcs. Defaults to '{}_kw' where {} is replaced with f.__name__.

  • **named – functions to nest. The key is used as the argument name in the parent function.

def funcA(a, b):
    """Another function

    Arguments:
        a (int): a from funcA
        b (int): b from funcA
    """

def funcB(b, c):
    """Anotherrrr function

    Arguments:
        b (int): b from funcB
        c (int): c from funcB
    """


def funcC(**kw):
    """Hello"""
funcD = nested_doc(funcA, funcB)(funcC)

print(funcD.__doc__)
"""
Hello

Args:
    funcA_kw (dict?): Keyword arguments for ``funcA``.

            - a (int): a from funcA
            - b (int): b from funcA
    funcB_kw (dict?): Keyword arguments for ``funcB``.

            - b (int): b from funcB
            - c (int): c from funcB
"""