about summary refs log tree commit diff
path: root/docs/dev
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-05-02 15:57:19 +0000
committerbors <bors@rust-lang.org>2023-05-02 15:57:19 +0000
commitc9b4116a5e8ef956066c9aca51e3adbaa1647fcb (patch)
treecd49d0fe266e0994954eeec93fbca057167782cb /docs/dev
parent4ecd7e6c0d25ed9a83bf94e49c63d0b6919c22f0 (diff)
parent2025f17ac394fc75528bb61422f15c5861a0fa8b (diff)
downloadrust-c9b4116a5e8ef956066c9aca51e3adbaa1647fcb.tar.gz
rust-c9b4116a5e8ef956066c9aca51e3adbaa1647fcb.zip
Auto merge of #14662 - Ddystopia:open_locally_built_documentatin_instead_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.
Diffstat (limited to 'docs/dev')
-rw-r--r--docs/dev/lsp-extensions.md26
1 files changed, 19 insertions, 7 deletions
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md
index a4ad3e5a553..bc58aa7220d 100644
--- a/docs/dev/lsp-extensions.md
+++ b/docs/dev/lsp-extensions.md
@@ -1,5 +1,5 @@
 <!---
-lsp_ext.rs hash: fdf1afd34548abbc
+lsp_ext.rs hash: 2d60bbffe70ae198
 
 If you need to change the above hash to make the test pass, please check if you
 need to adjust this doc as well and ping this issue:
@@ -386,14 +386,26 @@ rust-analyzer supports only one `kind`, `"cargo"`. The `args` for `"cargo"` look
 
 ## Open External Documentation
 
-This request is sent from client to server to get a URL to documentation for the symbol under the cursor, if available.
+This request is sent from the client to the server to obtain web and local URL(s) for documentation related to the symbol under the cursor, if available.
 
-**Method** `experimental/externalDocs`
+**Method:** `experimental/externalDocs`
 
-**Request:**: `TextDocumentPositionParams`
+**Request:** `TextDocumentPositionParams`
+
+**Response:** `string | null`
 
-**Response** `string | null`
+## Local Documentation
 
+**Experimental Client Capability:** `{ "localDocs": boolean }`
+
+If this capability is set, the `Open External Documentation` request returned from the server will have the following structure:
+
+```typescript
+interface ExternalDocsResponse {
+    web?: string;
+    local?: string;
+}
+```
 
 ## Analyzer Status
 
@@ -863,7 +875,7 @@ export interface Diagnostic {
 export interface FetchDependencyListParams {}
 ```
 
-**Response:** 
+**Response:**
 ```typescript
 export interface FetchDependencyListResult {
     crates: {
@@ -873,4 +885,4 @@ export interface FetchDependencyListResult {
     }[];
 }
 ```
-Returns all crates from this workspace, so it can be used create a viewTree to help navigate the dependency tree.
\ No newline at end of file
+Returns all crates from this workspace, so it can be used create a viewTree to help navigate the dependency tree.