vscode: Support opening local documentation if available

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.
This commit is contained in:
Elias Holzmann 2023-10-08 03:52:15 +02:00
parent 3dfc1bfc67
commit e8372e0484
3 changed files with 25 additions and 2 deletions

View file

@ -135,7 +135,11 @@ export const onEnter = new lc.RequestType<lc.TextDocumentPositionParams, lc.Text
export const openCargoToml = new lc.RequestType<OpenCargoTomlParams, lc.Location, void>(
"experimental/openCargoToml",
);
export const openDocs = new lc.RequestType<lc.TextDocumentPositionParams, string | void, void>(
export interface DocsUrls {
local: string | void;
web: string | void;
}
export const openDocs = new lc.RequestType<lc.TextDocumentPositionParams, DocsUrls, void>(
"experimental/externalDocs",
);
export const parentModule = new lc.RequestType<