Skip to content
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

Feature request: Open docs for symbol should support locally built documentation #12867

Closed
crumblingstatue opened this issue Jul 25, 2022 · 3 comments · Fixed by #15728
Closed
Labels
A-ide general IDE features C-feature Category: feature request

Comments

@crumblingstatue
Copy link

Rust-analyzer has a feature to open the docs for the symbol under the cursor, but it always uses docs.rs.
One could be using different versions of crates that aren't on docs.rs, like git dependencies, and also your local crate(s) aren't on docs.rs either.

Open docs should do a best-effort detection of locally built documentation (usually $TARGET_DIR/doc), and open that if the symbol is available under that, before falling back to docs.rs.

@lowr lowr added C-feature Category: feature request A-ide general IDE features labels Nov 12, 2022
@Ddystopia
Copy link
Contributor

Should it generate latest docs if they are not up to date?

@crumblingstatue
Copy link
Author

That's a good question. Would there be any drawbacks to that behavior?
But I think this can be implemented later, and for now it could just detect whether local documentation exists and use it if available.

bors added a commit that referenced this issue May 2, 2023
…ead_of_docs_dot_rs, r=Ddystopia

 Provide links to locally built documentation for `experimental/externalDocs`

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:

   - Added support for local documentation links alongside web documentation links.
   - Added `target_dir` path argument for external_docs and other related methods.
   - Added `sysroot` argument for external_docs.
   - Added `target_directory` path to `CargoWorkspace`.

API Changes:

   - Added an experimental client capability `{ "localDocs": boolean }`. If this capability is set, the `Open External Documentation` request returned from the server will include both web and local documentation links in the `ExternalDocsResponse` object.

Here's the `ExternalDocsResponse` interface:

```typescript
interface ExternalDocsResponse {
    web?: string;
    local?: string;
}
```

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.
@Veykril Veykril closed this as completed May 2, 2023
@lnicola lnicola reopened this May 8, 2023
@lnicola
Copy link
Member

lnicola commented May 8, 2023

Reopening because #14662 didn't add the client support for Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ide general IDE features C-feature Category: feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants