microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.7k stars 767 forks source link

Improve formatting of parameter hints (call tooltips) #1849

Closed memeplex closed 3 years ago

memeplex commented 5 years ago

Environment data

Expected behaviour

Tooltip text flows naturally disregarding hard breaks in the original docstring.

Actual behaviour

Natural text flow is interrupted because of the interaction between the width of the tooltip popup and the location of hard breaks in the docstring (which assume a larger viewport).

image

ISSUE HERE

of several
input
planes

Hardbreak after "input" interrupt the natural flow.

Steps to reproduce:

JEDI AS INTELLISENSE IS SELECTED

  1. Create a python file
  2. import torch
  3. torch.nn.Conv2d(
  4. wait for the signature help

Some suggestions

Many editors (vscode included) provide heuristic text formatters as builtins or as extensions.

Moreover, font size could be reduced (indeed, for a tooltip, current size looks too big). Atom does this and the popups are really not much larger than vscode ones, but the layout of the text is superior.

Related issues

https://github.com/microsoft/vscode-python/issues/5577, https://github.com/microsoft/vscode-python/issues/5610, https://github.com/microsoft/vscode/issues/14165, https://github.com/microsoft/vscode/issues/38663

Some of the referenced issues suggest that changes upstream could improve the situation for vscode-python, but anyway I believe there still is room for improvement and no popup width short of 80 characters will ever be right, anyway.

karrtikr commented 5 years ago

I don't see a "hardbreaks" issue with argparse.ArgumentParser. That is separate issue taken care in microsoft/vscode-python#5577 The "hardbreaks" issue occurs with torch.

I have edited the issue accordingly.

memeplex commented 5 years ago

This is interesting, notice how well the documentation for os is formatted here:

image

There original has hard breaks like this:

Programs that import and use 'os' stand a better chance of being
portable between different platforms.  Of course, they must then
only use functions that are defined by all platforms (e.g., unlink
and opendir), and leave all pathname manipulation to os.path
(e.g., split and join).

Some kind of processing is happening there, don't you think?

karrtikr commented 5 years ago

Agree, can you please comment these queries on the upstream jedi issue. The maintainers of jedi would know more about it.

memeplex commented 5 years ago

Do these better formatted queries also come already formatted from jedi?

luabud commented 5 years ago

We do post-processing of this

DarkSystemCD commented 3 years ago

productivity with parameter hint in vscode could have monospace font and rendered in pre tag by default;

how to write in free typing, consistent documentation in vscode [?] since vscode is built in css and html, you developers could just add a pre tag with monospace font where parameter hint custom content are rendered;

jakebailey commented 3 years ago

As with #1848, I believe this is fine in Pylance.