Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python setting to not include type annotations in docstrings #97

Closed
xbe opened this issue Sep 6, 2020 · 4 comments
Closed

Add Python setting to not include type annotations in docstrings #97

xbe opened this issue Sep 6, 2020 · 4 comments

Comments

@xbe
Copy link

xbe commented Sep 6, 2020

Take, for example, this function:

def foo(x: int) -> None:

This is the generated Google-style docstring:

def foo(x: int) -> None:
    """[TODO:summary]

    [TODO:description]

    Args:
        x (int): [TODO:description]

    Returns:
        None: [TODO:description]
    """

It would be nice to have the option to generate this instead:

def foo(x: int) -> None:
    """[TODO:summary]

    [TODO:description]

    Args:
        x: [TODO:description]

    Returns:
        [TODO:description]
    """
@kkoomen
Copy link
Owner

kkoomen commented Oct 8, 2020

I did fix it, but I simply removed the type from the generated docblock because Google never defined this. I have zero clue why I added this, but it's fixed.

@kkoomen kkoomen closed this as completed Oct 8, 2020
@kkoomen
Copy link
Owner

kkoomen commented Oct 8, 2020

This bug has been fixed and released in v3.0.1.

Feel free to submit any new issues if you experience any unwanted behavior in the future. Thanks for your contribution.

@daturkel
Copy link

I can make a separate issue if necessary, but I'd love to have types omitted from the params section of the docstring if annotations are in the function signature for numpy style

The Sphinx documentation shows the following examples for numpy-style docstrings:

def function_with_types_in_docstring(param1, param2):
    """Example function with types documented in the docstring.

    `PEP 484`_ type annotations are supported. If attribute, parameter, and
    return types are annotated according to `PEP 484`_, they do not need to be
    included in the docstring:

    Parameters
    ----------
    param1 : int
        The first parameter.
    param2 : str
        The second parameter.

    Returns
    -------
    bool
        True if successful, False otherwise.

    .. _PEP 484:
        https://www.python.org/dev/peps/pep-0484/

    """


def function_with_pep484_type_annotations(param1: int, param2: str) -> bool:
    """Example function with PEP 484 type annotations.

    The return type must be duplicated in the docstring to comply
    with the NumPy docstring style.

    Parameters
    ----------
    param1
        The first parameter.
    param2
        The second parameter.

    Returns
    -------
    bool
        True if successful, False otherwise.

    """

However, currently Doge includes types in the Parameters section regardless of whether type annotations are present.

@kkoomen
Copy link
Owner

kkoomen commented Nov 30, 2020

@daturkel Please make a new issue and I'll look at it later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants