microsoft / pylance-release

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

missing new line from dict() help mouse hover #3118

Closed Devid-Ba closed 3 months ago

Devid-Ba commented 2 years ago

Environment data

Code Snippet

XXX

Repro Steps

  1. hover over dict()

Expected behavior

newline after d = {}.

Actual behavior

Screenshot from 2022-07-31 17-32-36

screen shot from help(dict) Screenshot from 2022-07-31 17-33-37

Logs

XXX
heejaechang commented 2 years ago

doc string formatter issue.

rchiodo commented 3 months ago

Looking at this in the context of supporting restructured text. Builtins are not in restructured text format.

The docstring for dict for example is this:

dict() -> new empty dictionary
dict(mapping) -> new dictionary initialized from a mapping object's
    (key, value) pairs
dict(iterable) -> new dictionary initialized as if via:
    d = {}
    for k, v in iterable:
        d[k] = v
dict(**kwargs) -> new dictionary initialized with the name=value pairs
    in the keyword argument list.  For example:  dict(one=1, two=2)

Parsing this into rest, it's just one big paragraph.

image

Paragraphs (when shown in Markdown) eliminate extra tabs on purpose. Otherwise something like this wouldn't wrap correctly:

this is a paragraph with extra
   lines that continue after a tab.
rchiodo commented 3 months ago

Builtins may then have to be formatted literally. Or at least special cased to add literal indents.

rchiodo commented 3 months ago

This issue has been fixed in prerelease version 2024.6.100, which we've just released. You can find the changelog here: CHANGELOG.md

rchiodo commented 3 months ago

The fix for this issue is behind an experimental feature flag:

"python.analysis.supportRestructuredText": true

If you want to try out our new restructuredText support, enable this flag. It's behind a flag at the moment until we can make sure it handles all the possible Sphinx/GoogleDoc/Epytext scenarios that customers need. Please log additional issues if this setting isn't working out for you.

Thanks :)