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

Classify themes as light/dark and fallback to the base light/dark theme if theme does not exist #74937

Closed
Nemo157 opened this issue Jul 30, 2020 · 4 comments
Labels
A-rustdoc-themes Area: Themes for HTML pages generated by rustdoc T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Nemo157
Copy link
Member

Nemo157 commented Jul 30, 2020

See rust-lang/docs.rs#919 for some context.

When browsing docs within a single Web context (a.k.a. a single instance of LocalStorage, mostly based on the domain but also affected by other details) generated from multiple versions of rustdoc (or with custom themes) you may set the selected theme to one that does not exist in all the documentation. When loading a page with an unknown theme rustdoc will just leave the theme as the default light theme, which can result in suddenly been blinded if generally using a dark theme in a dark room.

To avoid the binding effect it would be good to have all builtin (and custom) themes classified into light or dark, and fallback to the base light/dark theme as appropriate when the exact theme requested is unknown. This will have to be implemented something like storing the classification into local-storage alongside the theme itself, since the rustdoc JS loading the theme will not know the theme to classify it itself.

If anyone can think of a plan that is backwards compatible with both pre-ayu rustdoc, and the current nightlies with ayu available, it'd be great if we can get this working across all versions on docs.rs somehow; but I doubt this is possible, so probably best to focus on just getting something that works on documentation generated going forward.

@Nemo157
Copy link
Member Author

Nemo157 commented Jul 30, 2020

@rustbot modify labels: +T-rustdoc

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jul 30, 2020
@pickfire
Copy link
Contributor

Isn't it better to fallback to the system default theme? If the system uses dark theme I don't know why should it fallback to a light theme. Personally, I wish there is an automatic light/dark theme (can be done using css only), my phone automatically switches the system light/dark setting depending on the time, I bet other phones have this feature too.

@jyn514 jyn514 added the A-rustdoc-themes Area: Themes for HTML pages generated by rustdoc label Aug 25, 2020
@jyn514
Copy link
Member

jyn514 commented Oct 11, 2020

Related: #77809

@GuillaumeGomez
Copy link
Member

As far as I can tell, it was fixed by #77809. Don't hesitate to reopen this issue if something from this issue is still missing though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-themes Area: Themes for HTML pages generated by rustdoc T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants