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

RFE - extract docstring for params from function docstring #739

Closed
DonJayamanne opened this issue Jul 1, 2016 · 7 comments
Closed

RFE - extract docstring for params from function docstring #739

DonJayamanne opened this issue Jul 1, 2016 · 7 comments

Comments

@DonJayamanne
Copy link
Contributor

@DonJayamanne DonJayamanne commented Jul 1, 2016

Currently when getting the parameter information, the docstring is empty.
Could we not extract (via some string parsing) extract this from the docstring and return this information along with the param info.

@DonJayamanne DonJayamanne changed the title RFE - extract docstring for params from class docstring RFE - extract docstring for params from function docstring Jul 1, 2016
@davidhalter
Copy link
Owner

@davidhalter davidhalter commented Jul 1, 2016

What are you talking about?

@DonJayamanne
Copy link
Contributor Author

@DonJayamanne DonJayamanne commented Jul 1, 2016

Sorry, let me be more specific:
Today when we call the method call_getsignatures, the docstring for the signature is returned when using the docstring() method.
When iterating through the parameters of each signature using the "params" property, the docstring() for each of the parameters is empty.

My suggestion is why not determine the documentation of the corresponding parameter from the docstring of the function.

For instance the docstring for function_with_types_in_docstring can be extracted and is returned by jedi.
How about some how trying to parse that string to extract the documentation for the individual parameters?

However, there's a problem in supporting various docstring formats.

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:

    Args:
        param1 (int): The first parameter.
        param2 (str): The second parameter.

    Returns:
        bool: The return value. True for success, False otherwise.

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

    """
@davidhalter
Copy link
Owner

@davidhalter davidhalter commented Jul 6, 2016

You are right. This would be a good idea. Parsing it is probably not that hard, since such logic already exists. (jedi/evaluate/docstrings.py). However I'm not actually sure on all the API implications.

@DonJayamanne
Copy link
Contributor Author

@DonJayamanne DonJayamanne commented Jul 6, 2016

I agree, maintaining backwards compatibility is necessary as this is widely used. How about we add this feature as an optional one, via an optional parameter to call_Getsignatures. I am more than happy to submit a pull request if you think this is the right approach.

@davidhalter
Copy link
Owner

@davidhalter davidhalter commented Jan 5, 2020

@DonJayamanne Sorry for not answering back then. Are you still interested in doing such a pull request?

I unfortunately don't really like working with docstrings and so I'm probably not going to do it :).

@davidhalter
Copy link
Owner

@davidhalter davidhalter commented Jan 22, 2020

Closing for now. Happy to reopen if someone feels like they want to work on this :).

@DonJayamanne
Copy link
Contributor Author

@DonJayamanne DonJayamanne commented Jan 22, 2020

Sorry for not answering back then. Are you still interested in doing such a pull request?

Oops, sorry for not replying. Somehow missed the original message.
I'm happy for this to be closed. Thanks for considering it.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.