zed icon indicating copy to clipboard operation
zed copied to clipboard

rust: add Open Documentation support

Open andrewbanchich opened this issue 1 year ago • 1 comments

Check for existing issues

  • [X] Completed

Describe the feature

in other editors i can select "Open Documentation" and it will open the docs.rs site for that item in the browser.

If applicable, add mockups / screenshots to help present your vision of the feature

No response

andrewbanchich avatar Oct 09 '24 15:10 andrewbanchich

I believe this is rust-analyzer.openDocs https://rust-analyzer.github.io/manual.html#open-docs

notpeter avatar Oct 09 '24 18:10 notpeter

I've already written the code to support that feature, and I'll submit a PR later.

wanlufun avatar Oct 15 '24 16:10 wanlufun

Not sure if this is possible, but could this eventually build and open local documentation sites for private crates which are not available on docs.rs?

andrewbanchich avatar Oct 17 '24 10:10 andrewbanchich

Not sure if this is possible, but could this eventually build and open local documentation sites for private crates which are not available on docs.rs?

        workspace.update(&mut cx, |_workspace, cx| {
            // Check if the local document exists, otherwise fallback to the online document.
            // Open with the default browser.
            if let Some(local_url) = docs_urls.local {
                if fs::metadata(Path::new(&local_url[8..])).is_ok() {
                    cx.open_url(&local_url);
                    return;
                }
            }

            if let Some(web_url) = docs_urls.web {
                cx.open_url(&web_url);
            }
        })

Rust-analyzer does provide this functionality. After generating the local documentation with cargo doc, you can use the open docs command to open the local documentation (including private crates). You can test this feature in VSCode, and it should meet your needs.

wanlufun avatar Oct 18 '24 06:10 wanlufun

Awesome, thank you!

andrewbanchich avatar Oct 18 '24 07:10 andrewbanchich

You’re welcome! I'm glad you liked it!

On Fri, Oct 18, 2024 at 3:33 PM Andrew Banchich @.***> wrote:

Awesome, thank you!

— Reply to this email directly, view it on GitHub https://github.com/zed-industries/zed/issues/18924#issuecomment-2421653976, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4ABU2B462HJQ2YB2CKUCVTZ4C2S3AVCNFSM6AAAAABPU2YFH6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRRGY2TGOJXGY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

wanlufun avatar Oct 18 '24 07:10 wanlufun