Docstring references could have links that goto def on the reference
Given a docstring like so:
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:
We could also do this automatically in spots where we know something is a type. Like parameter types.
Additionally, I think it would be nice if references prefixed with ~ were rendered correctly (i.e. only the last part). Currently:
Let me know if I should open a new issue for this one!
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
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.