autoDocstring icon indicating copy to clipboard operation
autoDocstring copied to clipboard

Parser gets confused with comments

Open GabrielSchoenweiler opened this issue 2 years ago • 1 comments
trafficstars

Description when I place a comment next to an argument, the parser stops right on the comment.

Versions:

autoDocstring Version: v0.6.1
Operating System: Win 10
Vscode Version: 1.73.0

Original Code (with line to generate on):

def TestFxn(self,
            arg0: int,   # comment
            arg1: str,   # comment
            arg2: float
            ) -> int:
    print(f"{arg0}, {arg1}, {arg2}")
    return len(arg1)

Expected Result:

def TestFxn(self,
            arg0: int,   # comment
            arg1: str,   # comment
            arg2: float
            ) -> int:
    """_summary_

    Args:
        arg0 (int): _description_
        arg1 (str): _description_
        arg2 (float): _description_

    Returns:
        int: _description_
    """
    print(f"{arg0}, {arg1}, {arg2}")
    return len(arg1)

Actual Result:

def TestFxn(self,
            arg0: int,   # comment
            arg1: str,   # comment
            arg2: float
            ) -> int:
    """_summary_

    Args:
        arg0 (int): _description_

    Returns:
        int: _description_
    """
    print(f"{arg0}, {arg1}, {arg2}")
    return len(arg1)

It gets even better, when I use a comment, that contains a comma:

def TestFxn(self,
            arg0: int,   # comment
            arg1: str,   # comment with comma, text after comma
            arg2: float
            ) -> int:
    """_summary_

    Args:
        arg0 (int): _description_
        textaftercommaarg2 (float): _description_

    Returns:
        int: _description_
    """
    print(f"{arg0}, {arg1}, {arg2}")
    return len(arg1)

GabrielSchoenweiler avatar Jan 24 '23 15:01 GabrielSchoenweiler

I noticed this problem recently as well, would love to see a PR for this

rawrke avatar Jul 26 '23 14:07 rawrke