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

Parser gets confused with comments #252

Open
GabrielSchoenweiler opened this issue Jan 24, 2023 · 1 comment · May be fixed by #280
Open

Parser gets confused with comments #252

GabrielSchoenweiler opened this issue Jan 24, 2023 · 1 comment · May be fixed by #280
Labels

Comments

@GabrielSchoenweiler
Copy link

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)
@rawrke
Copy link

rawrke commented Jul 26, 2023

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

@PhilipNelson5 PhilipNelson5 linked a pull request Apr 2, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants