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

Setting ayu theme on new docs falls back to light theme on old docs #919

Open
Nemo157 opened this issue Jul 29, 2020 · 8 comments
Open

Setting ayu theme on new docs falls back to light theme on old docs #919

Nemo157 opened this issue Jul 29, 2020 · 8 comments
Labels
A-frontend Area: Web frontend E-easy Effort: Should be easy to implement and would make a good first PR

Comments

@Nemo157
Copy link
Member

Nemo157 commented Jul 29, 2020

If you go to newly generated docs like https://docs.rs/tokio/0.2.22/tokio/ and set your theme to ayu, then navigate to old docs like https://docs.rs/tokio/0.2.21/tokio/ it will fallback to the light theme since ayu doesn't exist and blind the user.

It might be possible to inject a little docs.rs specific JS to cause ayu to fallback to the dark theme instead.

@jyn514
Copy link
Member

jyn514 commented Jul 29, 2020

This seems like a duplicate of #464? Why should ayu be singled out specifically?

@Nemo157
Copy link
Member Author

Nemo157 commented Jul 29, 2020

I'm going to pull a quote from internals that hopefully provides good context:

There is nothing worse than having everything dark and using your computer in a dim or dark area and then switching to an application or web page where suddenly most of the screen is bright/light. It feels like someone just shot a laser beam into your eyes (which considering that most screens are now OLED, isn't far from the truth).

https://internals.rust-lang.org/t/in-next-nightly-currently-one-doesnt-have-new-css-rules/12807/4

Since we do have a fallback option in this case in that the majority of old documentation (and "old" in this case is only a few weeks) has the dark theme available I think it's worth seeing if we can make life easier for dark-mode users (I may be biased in that I'm one of them, but I also use the ayu usercss which injects the ayu theme into old docs as well so I don't have this issue myself anyway 😁).

@jyn514
Copy link
Member

jyn514 commented Jul 29, 2020

Hmm ... unlike most of the other CSS this is actually feasible because it's an entirely new file instead of a slightly modified one. Maybe we could notice the 404 looks like ayu-*.css and substitute the * for the most recent version if so? And do the same for dark mode. That might look a little odd since the page structure has changed but hopefully it will get most of the way there.

@jyn514 jyn514 added A-frontend Area: Web frontend E-easy Effort: Should be easy to implement and would make a good first PR labels Jul 29, 2020
@Mark-Simulacrum
Copy link
Member

Regardless of what we do in docs.rs, it probably makes sense to have an upstream rustdoc fix that classifies themes as light/dark and falls back appropriately when switching.

@jyn514
Copy link
Member

jyn514 commented Jul 29, 2020

upstream rustdoc fix

That won't help with this problem, which is about documentation generated before rustdoc got an Ayu theme. Any fix we upstream won't be applied to the existing docs.

@Mark-Simulacrum
Copy link
Member

Yes, but in the future (if we choose to add more themes) I'd prefer to avoid piling on more "if somenewtheme-*.css, light" in docs.rs.

@Nemo157
Copy link
Member Author

Nemo157 commented Jul 30, 2020

Opened rust-lang/rust#74937 as an upstream issue to handle this automatically in the future. We probably don't want to do anything till that is done, then maybe we can have a smidgen of JS that backports that change into old docs (or decide that it's not worth supporting and wait for old docs to age out).

@ModProg
Copy link

ModProg commented Apr 24, 2022

Opened rust-lang/rust#74937 as an upstream issue to handle this automatically in the future. We probably don't want to do anything till that is done, then maybe we can have a smidgen of JS that backports that change into old docs (or decide that it's not worth supporting and wait for old docs to age out).

The upstream issue was closed, tho I'm not sure in a way that helps here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: Web frontend E-easy Effort: Should be easy to implement and would make a good first PR
Projects
None yet
Development

No branches or pull requests

4 participants