-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide links to locally built documentation for experimental/externalDocs
#14662
Provide links to locally built documentation for experimental/externalDocs
#14662
Conversation
Can this be implemented in a backward compatible way? I.e., clients conforming to the current extension might fail in the future because the type of the return value has changed. (One possibility to overcome this issue is make rust-analyzer check for a client capability like, for example, Also, does the local documentation count as "external documentation"? Thank you. |
As far as I know, rust-analyzer does not provide a stable API interface, so breakage is fine.
I assume that "external documentation" is documentation outside of the editor. Maybe, it would be better to create something like Thank you for your comment. |
34be699
to
7831b2b
Compare
Maybe you're right. But to me, this text only says how plugin-maintainers can keep up with the changes of the lsp-extensions and says nothing about a possible breakage.
I don't know, but I start to wonder why it is necessary to introduce protocol extensions for this feature. The LSP client can send a standard compliant |
☔ The latest upstream changes (presumably #14664) made this pull request unmergeable. Please resolve the merge conflicts. |
037798c
to
1abf405
Compare
☔ The latest upstream changes (presumably #11557) made this pull request unmergeable. Please resolve the merge conflicts. |
… links, pending for `target_dir` path and tests
Co-authored-by: Lukas Wirth <[email protected]>
1abf405
to
f24cdf3
Compare
two nits, otherwise lgtm, thanks! |
✌️ @Ddystopia can now approve this pull request |
How is using |
f24cdf3
to
2025f17
Compare
@bors r+ |
☀️ Test successful - checks-actions |
As the showDocument request supports an "external" flag, the server can implement the logic of determining how the client should open the documentation. This way the client-side code can be smaller, which is a desirable goal, I think. At any rate, I'm happy with the merged feature. Thanks @Ddystopia and @Veykril! |
…de, r=Veykril feat: vscode: Support opening local documentation if available This PR implements the VS code support for opening local documentation (server side support was already implemented in #14662). [local_docs.webm](https://github.com/rust-lang/rust-analyzer/assets/9659253/715b84dd-4f14-4ba0-a904-749b847eb3d5) Displaying local instead of web docs can have many benefits: - the web version may have different features enabled than locally selected - the standard library may be a different version than is available online - the user may not be online and therefore cannot access the web documentation - the documentation may not be available online at all, for example because it is for a new feature in a library the user is currently developing If the documentation is not available locally, the extension still falls back to the web version. Closes #12867. ----- If my implementation isn't really idiomatic TypeScript: Sorry, I'm not much of a TypeScript developer. I am open to feedback, however.
This pull request addresses issue #12867, which requested the ability to provide links to locally built documentation when using the "Open docs for symbol" feature. Previously, rust-analyzer always used docs.rs for this purpose. With these changes, the feature will provide both web (docs.rs) and local documentation links without verifying their existence.
Changes in this PR:
target_dir
path argument for external_docs and other related methods.sysroot
argument for external_docs.target_directory
path toCargoWorkspace
.API Changes:
{ "localDocs": boolean }
. If this capability is set, theOpen External Documentation
request returned from the server will include both web and local documentation links in theExternalDocsResponse
object.Here's the
ExternalDocsResponse
interface:By providing links to both web-based and locally built documentation, this update improves the developer experience for those using different versions of crates, git dependencies, or local crates not available on docs.rs. Rust-analyzer will now provide both web (docs.rs) and local documentation links, leaving it to the client to open the desired link. Please note that this update does not perform any checks to ensure the validity of the provided links.