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

Docstring Formatting in autocomplete suggestion #721

Closed
sagarchalise opened this issue Jun 10, 2020 · 6 comments
Closed

Docstring Formatting in autocomplete suggestion #721

sagarchalise opened this issue Jun 10, 2020 · 6 comments
Labels
enhancement request New feature or request

Comments

@sagarchalise
Copy link

Is your feature request related to a problem? Please describe.
Currently the autocomplete docstring format is not that readable. Is it possible to show docstrings as is ? I am using google style.
Screenshot from 2020-06-10 13-00-24

Describe the solution you'd like
I think docstring shown by vscode-python is nice. It would be nice if some formatting could be done to docstring when shown in suggestion.

@sagarchalise sagarchalise added the enhancement request New feature or request label Jun 10, 2020
@erictraut
Copy link
Collaborator

Thanks for the suggestion.

Could you provide a more detailed example that includes some original docstrings and what you think they should look like when displayed in completion results?

We are somewhat limited by the way in which VS Code and other language clients display completion results, which are provided in markdown format.

@erictraut erictraut added the question Further information is requested label Jun 10, 2020
@sagarchalise
Copy link
Author

sagarchalise commented Jun 10, 2020

@erictraut Basically here is the suggestion on same definition from vscode-python. As you can see the docstring is formatted as is and not stripped.
Screenshot from 2020-06-10 21-23-39

Here is some example taken from sphinx napolean extension

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

   Args:
       param1: The first parameter.
       param2: The second parameter.

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

   """
   return bool(param1 + param2)

this is rendered as

(method) function_with_pep484_type_annotations: (param2: str) -> bool
Example function with PEP 484 type annotations.

Args: param1: The first parameter. param2: The second parameter.

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

@jakebailey
Copy link
Member

jakebailey commented Jun 10, 2020

FWIW that image is taken with the vscode-python extension with Jedi enabled; in this case no special processing is done (the text is copied 1:1), which has its own downsides. E.g., you can see that the indention of the block means it's being treated as a markdown code block with a monospaced font and awkward text wrapping. If you enable the language server, the tooltips will look the same as your original screenshot (which uses the same heuristical conversion to attempt to make any docstring into somewhat-good looking markdown).

The numpy/google/sphinx format's section block (like args) is one case that doesn't look so good with the conversion, and does stand to be improved.

@msfterictraut msfterictraut removed the question Further information is requested label Jun 11, 2020
@msfterictraut
Copy link
Collaborator

As Jake said, there are pros/cons to both approaches. To me, the JEDI formatting looks worse (is harder to read) than the formatting used by MPLS and Pyright. I agree that neither of them are ideal.

@sagarchalise
Copy link
Author

It seems it is being discussed in vscode-python as well.

@erictraut
Copy link
Collaborator

This is a duplicate of feature request being discussed in the pylance-release repo. microsoft/pylance-release#48
Also related to this issue: microsoft/pylance-release#41
I'm going to close this bug and use the others to track this issue.

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

No branches or pull requests

4 participants