terrencepreilly / darglint

A python documentation linter which checks that the docstring description matches the definition.
MIT License
483 stars 41 forks source link

Argument parsing #158

Closed ariG23498 closed 3 years ago

ariG23498 commented 3 years ago

With the google doc style I try writing a docstring in this format

def model(a,b):
    """
    This is a model

    Args:
        a (int): This is the step
        b (float): This is the learning rate

    Returns:
        The multiplication of a and b
    """
    return a*b

I think the right task would be to throw an error stating that arguments must always be followed by a colon and not space. This check could be vital for an automatic documentation generation that solely depends on the position of the colon. Could there be a quick fix to this?

terrencepreilly commented 3 years ago

Are you saying you don't think it should allow type annotations in the docstring? (Like, you think your first argument should be a: this is the step and not a (int): This is the step?) Type annotations are actually required by the style guide if they're missing from the docstring. So disallowing them isn't something I'd support.

Feel free to correct me in a comment. For now, I'll close this.

ariG23498 commented 3 years ago

So I think that we should provide type annotations but should have a way to also know where the colon lies. a: (int) This is a step. I would like to know if there is a workaround to let the linter throw an error upon where the colon is placed.

terrencepreilly commented 3 years ago

The format for type annotations are taken from the napolean extension for sphinx, and it also seems to be the most widely used format.

If you have some particular use-case in mind, you're welcome to fork the repository and update the parser. It shouldn't be too difficult.