NilsJPWerner / autoDocstring

VSCode extension that generates docstrings for python files
MIT License
676 stars 162 forks source link

Numpy docstring with multiple returns #62

Open PeterFogh opened 6 years ago

PeterFogh commented 6 years ago

Hi,

As an extension of my issue #61, I also think it would be nice if the Numpy docstring factory numpy.ts would process multiple return values.

Hence, the following example:

def fun(a, b=1):
    """
    c = 1
    d = 'hello'
    return c, d

shold result in:

def fun(a, b=1):
    """
    [summary]

    [description]

    Parameters
    ----------
    a : [type]
        [description]
    b : int, optional
        [description] (the default is 1, which [default_description])

    Returns
    -------
    c : [type]
        [description]
    d: [type]
        [description]

    """
    c = 1
    d = 'hello'
    return c, d

but the extension currently outputs:

def fun(a, b=1):
    """
    [summary]

    [description]

    Parameters
    ----------
    a : [type]
        [description]
    b : int, optional
        [description] (the default is 1, which [default_description])

    Returns
    -------
    [type]
        [description]
    """

    c = 1
    d = 'hello'
    return c, d
beeb commented 4 years ago

I would even go as to say we could do this for google style docstrings (of course with a on/off toggle in the preferences).

def fun(a, b=1):
    """[summary]

    [extended_summary]

    Args:
        a ([type]): [description]
        b (int, optional): [description]. Defaults to 1.

    Returns:
        tuple: a tuple containing:
            - c ([type]): [description]
            - d ([type]): [description]
    """
    c = 1
    d = 'hello'
    return c, d
joaonizer commented 3 months ago

I would even go as to say we could do this for google style docstrings (of course with a on/off toggle in the preferences).

def fun(a, b=1):
    """[summary]

    [extended_summary]

    Args:
        a ([type]): [description]
        b (int, optional): [description]. Defaults to 1.

    Returns:
        tuple: a tuple containing:
            - c ([type]): [description]
            - d ([type]): [description]
    """
    c = 1
    d = 'hello'
    return c, d

This feature would be very welcoming, as currently I have to manually add all the tuple elements to the return list. And for some reason typing multiple returns in the Google style is breaking the format. I'm currently looking for solutions otherwise I will add a new bug.