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

Add command line option to print URL/path/link to generated documentation #5562

Closed
cpick opened this issue May 23, 2018 · 7 comments · Fixed by #12859
Closed

Add command line option to print URL/path/link to generated documentation #5562

cpick opened this issue May 23, 2018 · 7 comments · Fixed by #12859
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-doc

Comments

@cpick
Copy link

cpick commented May 23, 2018

I use cargo doc --open to generate/update docs and open them in a browser, but often I want to view them in a non-default browser. Sometimes I want to use the viewer built into my IDE, sometimes I'm testing out a new browser, etc.

It would be nice if either cargo doc printed the URL/path/link to the newly generated docs when it was done (similar to how cargo test prints "Running target/debug/deps/foo"), or if a new option like cargo doc --link, cargo doc --url, etc could be added to do this.

If either of these sounds like a reasonable idea I could take a crack at putting a pull request together?

@alexcrichton
Copy link
Member

Sounds like a reasonable idea to me!

@alexcrichton alexcrichton added Command-doc C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` labels May 23, 2018
@esteve
Copy link
Contributor

esteve commented May 29, 2018

@cpick I wasn't sure if you were working on this, so I've submitted #5592, which print the path to the generated docs. I hope I didn't step on your toes, if you already have started working on this I'm happy to withdraw my PR.

@cpick
Copy link
Author

cpick commented May 29, 2018

@esteve no I hadn't gotten to it, this is great!

@nic-hartley
Copy link

Any update on this? A --path like rustup doc --path would be very nice for people who use WSL, where none of the default browser commands work. --open will print the URL as part of the error message, but that only helps if you don't have something installed which might accept the command despite not actually showing a browser window. (e.g. I had to add a www-browser no-op script to get something else to work; luckily, it's no longer on my $PATH, so it didn't cause issues)

@kobenauf
Copy link

kobenauf commented Jan 8, 2020

As someone who uses Windows/WSL2, it would be nice to have rustup doc work. I can export BROWSER=firefox.exe, and then rustup doc --std opens firefox, but the browser is empty; no error, nothing in the URL bar.

From a bash window, if I run this:

firefox.exe file://///wsl$/Ubuntu/home/name_redacted/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/share/doc/rust/html/index.html

... Firefox opens to the Rust documentation I want. Could rustup doc potentially figure out that path for WSL?

@janpaul123
Copy link

Simple workaround: BROWSER=echo cargo doc --open

@nic-hartley
Copy link

@janpaul123 Clever! Although to be clear I'd still like to have proper support; this is a wonderful hack but still a hack haha

epage added a commit to epage/cargo that referenced this issue Oct 19, 2023
I've wanted something like this myself.  I dislike using `--open`
because I tend to move up to re-run my `cargo doc` run but then have to
edit it to remove `--open`.
Also makes it annoying when opening docs when `cargo doc` is wrapped by
a tool like `make`.

This was previously attempted in rust-lang#5592:
- Unlike the request in rust-lang#5562, this aligns with rust-lang#5592 in always printing
  rather than using a flag as this seems generally useful
- Unlike rust-lang#5592, this prints as an alternative to "Opening" to keep
  things light
- Unlike rust-lang#5592, this prints afterwards as the link is only valid then

Fixes rust-lang#5562
epage added a commit to epage/cargo that referenced this issue Oct 19, 2023
I've wanted something like this myself.  I dislike using `--open`
because I tend to move up to re-run my `cargo doc` run but then have to
edit it to remove `--open`.
Also makes it annoying when opening docs when `cargo doc` is wrapped by
a tool like `make`.

This was previously attempted in rust-lang#5592:
- Unlike the request in rust-lang#5562, this aligns with rust-lang#5592 in always printing
  rather than using a flag as this seems generally useful
- Unlike rust-lang#5592, this prints as an alternative to "Opening" to keep
  things light
- Unlike rust-lang#5592, this prints afterwards as the link is only valid then

Fixes rust-lang#5562
epage added a commit to epage/cargo that referenced this issue Oct 19, 2023
I've wanted something like this myself.  I dislike using `--open`
because I tend to move up to re-run my `cargo doc` run but then have to
edit it to remove `--open`.
Also makes it annoying when opening docs when `cargo doc` is wrapped by
a tool like `make`.

This was previously attempted in rust-lang#5592:
- Unlike the request in rust-lang#5562, this aligns with rust-lang#5592 in always printing
  rather than using a flag as this seems generally useful
- Unlike rust-lang#5592, this prints as an alternative to "Opening" to keep
  things light
- Unlike rust-lang#5592, this prints afterwards as the link is only valid then

Fixes rust-lang#5562
epage added a commit to epage/cargo that referenced this issue Oct 19, 2023
I've wanted something like this myself.  I dislike using `--open`
because I tend to move up to re-run my `cargo doc` run but then have to
edit it to remove `--open`.
Also makes it annoying when opening docs when `cargo doc` is wrapped by
a tool like `make`.

This was previously attempted in rust-lang#5592:
- Unlike the request in rust-lang#5562, this aligns with rust-lang#5592 in always printing
  rather than using a flag as this seems generally useful
- Unlike rust-lang#5592, this prints as an alternative to "Opening" to keep
  things light
- Unlike rust-lang#5592, this prints afterwards as the link is only valid then

Fixes rust-lang#5562
epage added a commit to epage/cargo that referenced this issue Oct 19, 2023
I've wanted something like this myself.  I dislike using `--open`
because I tend to move up to re-run my `cargo doc` run but then have to
edit it to remove `--open`.
Also makes it annoying when opening docs when `cargo doc` is wrapped by
a tool like `make`.

This was previously attempted in rust-lang#5592:
- Unlike the request in rust-lang#5562, this aligns with rust-lang#5592 in always printing
  rather than using a flag as this seems generally useful
- Unlike rust-lang#5592, this prints as an alternative to "Opening" to keep
  things light
- Unlike rust-lang#5592, this prints afterwards as the link is only valid then

Fixes rust-lang#5562
epage added a commit to epage/cargo that referenced this issue Oct 20, 2023
I've wanted something like this myself.  I dislike using `--open`
because I tend to move up to re-run my `cargo doc` run but then have to
edit it to remove `--open`.
Also makes it annoying when opening docs when `cargo doc` is wrapped by
a tool like `make`.

This was previously attempted in rust-lang#5592:
- Unlike the request in rust-lang#5562, this aligns with rust-lang#5592 in always printing
  rather than using a flag as this seems generally useful
- Unlike rust-lang#5592, this prints as an alternative to "Opening" to keep
  things light
- Unlike rust-lang#5592, this prints afterwards as the link is only valid then

Fixes rust-lang#5562
epage added a commit to epage/cargo that referenced this issue Oct 23, 2023
I've wanted something like this myself.  I dislike using `--open`
because I tend to move up to re-run my `cargo doc` run but then have to
edit it to remove `--open`.
Also makes it annoying when opening docs when `cargo doc` is wrapped by
a tool like `make`.

This was previously attempted in rust-lang#5592:
- Unlike the request in rust-lang#5562, this aligns with rust-lang#5592 in always printing
  rather than using a flag as this seems generally useful
- Unlike rust-lang#5592, this prints as an alternative to "Opening" to keep
  things light
- Unlike rust-lang#5592, this prints afterwards as the link is only valid then

Fixes rust-lang#5562
epage added a commit to epage/cargo that referenced this issue Oct 23, 2023
I've wanted something like this myself.  I dislike using `--open`
because I tend to move up to re-run my `cargo doc` run but then have to
edit it to remove `--open`.
Also makes it annoying when opening docs when `cargo doc` is wrapped by
a tool like `make`.

This was previously attempted in rust-lang#5592:
- Unlike the request in rust-lang#5562, this aligns with rust-lang#5592 in always printing
  rather than using a flag as this seems generally useful
- Unlike rust-lang#5592, this prints as an alternative to "Opening" to keep
  things light
- Unlike rust-lang#5592, this prints afterwards as the link is only valid then

Fixes rust-lang#5562
epage added a commit to epage/cargo that referenced this issue Oct 27, 2023
I've wanted something like this myself.  I dislike using `--open`
because I tend to move up to re-run my `cargo doc` run but then have to
edit it to remove `--open`.
Also makes it annoying when opening docs when `cargo doc` is wrapped by
a tool like `make`.

This was previously attempted in rust-lang#5592:
- Unlike the request in rust-lang#5562, this aligns with rust-lang#5592 in always printing
  rather than using a flag as this seems generally useful
- Unlike rust-lang#5592, this prints as an alternative to "Opening" to keep
  things light
- Unlike rust-lang#5592, this prints afterwards as the link is only valid then

Fixes rust-lang#5562
bors added a commit that referenced this issue Oct 27, 2023
feat(doc): Print the generated docs links

I've wanted something like this myself.  I dislike using `--open` because I tend to move up to re-run my `cargo doc` run but then have to edit it to remove `--open`.
Also makes it annoying when opening docs when `cargo doc` is wrapped by a tool like `make`.

This was previously attempted in #5592:
- Unlike the request in #5562, this aligns with #5592 in always printing rather than using a flag as this seems generally useful
- Unlike #5592, this prints as an alternative to "Opening" to keep things light
- Unlike #5592, this prints afterwards as the link is only valid then

Fixes #5562
@bors bors closed this as completed in 293f225 Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-doc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants