-
I want to make a Sphinx extension that adds hover text to code examples like what twoslash does for typescript code samples. I'd like to use an LSIF dump to get very precise type information and I think Pyright would be the most suitable tool for this since it already bundles a language server. I first tried to look for something generic that can query any language server to produce an LSIF dump but I haven't found anything promising. That's why I'm wondering if at least there's a way to do this for Pyright specifically. I also have other potential use-cases for the LSIF dump such as finding references to documented functions/classes in example files and displaying them (shamelessly inspired by https://twitter.com/wcrichton/status/1456112165744615426). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
As you mentioned, pyright is a language server, and it already provides hover text. It works with other language clients, so if you have an LSP-compatible language client, it should work. We don't currently have any plans to add support for generating LSIF dumps, nor would we want to maintain such functionality as part of the pyright code base. That said, pyright is open-source, so you could fork it and use it as the basis for a tool that generates LSIF output. The closest thing that pyright offers is the ability to create type stubs from a code base. You could use the It looks like there is at least one open-source project that generates LSIF dumps from a Python code base: https://github.com/sourcegraph/lsif-py. |
Beta Was this translation helpful? Give feedback.
As you mentioned, pyright is a language server, and it already provides hover text. It works with other language clients, so if you have an LSP-compatible language client, it should work.
We don't currently have any plans to add support for generating LSIF dumps, nor would we want to maintain such functionality as part of the pyright code base. That said, pyright is open-source, so you could fork it and use it as the basis for a tool that generates LSIF output. The closest thing that pyright offers is the ability to create type stubs from a code base. You could use the
createTypeStubs.ts
module as a template for how to do this.It looks like there is at least one open-source project that …