rust-lang / rustup

The Rust toolchain installer
https://rust-lang.github.io/rustup/
Apache License 2.0
6.11k stars 877 forks source link

file:// urls for doc incompatible with snap/flatpak/container-based-development #3112

Open ahayzen-kdab opened 1 year ago

ahayzen-kdab commented 1 year ago

Problem you are trying to solve

There are various issues around confinement and working with containers on Linux where the path of the html docs either ends up wrong or the browser does not have permission to open the html docs.

Solution you'd like

Provide an option to serve the docs as a port like mdbook serve ( https://rust-lang.github.io/mdBook/cli/serve.html ), maybe like rustup doc --serve

This allows for both confined applications and developing inside a container to then work as they don't need to access the html files via a path, but instead just open localhost:8080 etc.

Notes

This would resolve issues like #3110 #2997 #2988 as there is no issue with confinement on ports.

If this is something this is possible, it would be good for cargo doc --serve to also exist as the same problem occurs with cargo doc --open. And this would then make both rustup and cargo consistent with mdbook serve which has this ability.

Vaisakhkm2625 commented 1 year ago

I am only starting rust today (i tried once few month before )and i saw rustup doc --book is not working... This was my exact thought, why it is not served in a port.... https://github.dev/rust-lang/rustup/blob/89f103761e61b87d27070c65aae1f6c4d06c5855/src/cli/rustup_mode.rs#L1593

i guess this the implementation of rustup doc, and this helps anyone who wanted to make this feature...

or may be i will try in the future....

rbtcollins commented 1 year ago

I think a rustup doc serve feature would be nice.

HarrisonHemstreet commented 1 year ago

I am seeing this issue too

HarrisonHemstreet commented 1 year ago

@rbtcollins I would be very happy to take this task on. Any help you would be willing to give / able to give would be highly appreciated :slightly_smiling_face:

rbtcollins commented 1 year ago

The functional requirement is that rustup should be able to spawn a webserver pointing at the docs, as a new feature complementary to spawning a browser on the file:// url it does today.

Theres a lot of room for UX experimentation here:

I don't know whats right; my hunch is that something like the following would work ok:

I think adding a '--serve' option to the existing doc command would be ok, but it probably needs to default off as folk may have doc in scripts etc which would break. We can look at making serving the default as a future change.

HarrisonHemstreet commented 1 year ago

Sounds good! I'll try working on this! :slightly_smiling_face:

HarrisonHemstreet commented 1 year ago

@rustbot claim

donottellmetonottellyou commented 1 year ago

Is this being worked on? I have been using cargo-docs, but it doesn't seem to work on local crates, only the rust book.

djc commented 1 year ago

My impression is that it's not being worked on -- I don't see any related open PRs. @HarrisonHemstreet are you still intending to work on it?

rbtcollins commented 1 year ago

@donottellmetonottellyou rustup doc's scope is only documentation shipped by the rust project itself, not docs for local crates.

brettearle commented 7 months ago

G'day If @HarrisonHemstreet isn't currently working on this?, can I jump on board? I'll just put up a MVP --serve flag and serve it on 0. What's the convention in rust up, just std lib or do we have a web crate we like?

rbtcollins commented 7 months ago

@brettearle we use external crates that are license compatible; we're just about to introduce a pervasive tokio runtime, so I would suggest something async + tokio based.

brettearle commented 7 months ago

G'day, trying to use tokio inside cli/rustup and it's not allowing the import, it's in dependencies in cargo.toml but has flag workspace= true, is there something special to get this use statement to work? Sorry if this is obvious new to production rust

Audiosutras commented 5 days ago

Hello I just stumbled on this issue in Ubuntu as well. Any motion on the serve feature?

djc commented 5 days ago

Nope, it hasn't been a priority for us. If someone wants to help out, that would be great!