Function Docstring Generator

Hey all,
there are many tools/packages aimed towards building documentation from code, however I was wondering if someone could point me in the direction of a module designed to automatically generate function docstrings?
So something along the lines of

def my_func(n: int) -> int:
    return n*n

(now running the module from the commandline)

def my_func(n: int) -> int:
    """[summary placeholder]

        param1 (int) : [param1 placeholder]

        int: [Return value placeholder]
    return n*n

(Of course ideally with the possibility to choose between the Docstring style)

Thanks in advance :slight_smile:

Howdy Maurice,

I developed a library, which does it the other way round: you create a (standardized) doc-string and said library automatically adds the belonging dynamic type and range checking (code).

If that is interesting for you, have a look at:

Cheers, Dominik

Well, you can build one from the inspect module by examining the
function signature. I do a bit of that here:

which I use to produce mdoule README files in markdown format. It
enumerates the names in the module and makes documentation from the
function signatures and the function docstring. It’s customised to my
own foibles, but you could use it to see how to get the function
signature; that would let you construct a docstring template for your
function like what you suggest above.

Cameron Simpson

Thanks guys for your answers!
For anybody interested, I also came across pyment (GitHub - dadadel/pyment: Format and convert Python docstrings and generates patches), which basically is what I’m looking for :slight_smile: