pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

Docstring references could have links that goto def on the reference

Open rchiodo opened this issue 1 year ago • 3 comments

Given a docstring like so:

image

You can see that there a func references. These references are generally to modules inside the current one, meaning we could theoretically find them.

It would be super cool to turn these into clickable links that jump to the other reference. Like sphinx does:

image

We could also do this automatically in spots where we know something is a type. Like parameter types.

rchiodo avatar Jun 20 '24 22:06 rchiodo

Additionally, I think it would be nice if references prefixed with ~ were rendered correctly (i.e. only the last part). Currently:

image

Let me know if I should open a new issue for this one!

Viicos avatar Oct 01 '24 19:10 Viicos

Related vscode issues:

  • https://github.com/microsoft/vscode/issues/138783
  • https://github.com/microsoft/vscode/issues/181320

And Bill has a prototype: https://github.com/bschnurr/pyrx/commit/3ae67a89e8ea85910792b8fcf91bead4b7daf470

Java extension does something similar here: https://github.com/redhat-developer/vscode-java/blob/5f2d266cd7fe41dbe851b4ff7af283b66affe1d7/src/standardLanguageClient.ts#L878

debonte avatar Apr 07 '25 23:04 debonte

It's funny.

Hyperlinks have been invented about 60 years ago. Python about 35 years ago. But as of June 2, 2025, vscode/pylance don't yet support the trivial concept of cross refs in docstrings.

Tho I wouldn't touch vscode/pylance with a ten-foot pole, that's why I can find this funny.

Go MS go! Maybe for the first centennial of Python you'll eventually get it right.

jy-lefort avatar Jun 02 '25 09:06 jy-lefort