Skip to content

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

Closed
@Nemo157

Description

@Nemo157

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-themesArea: Themes for HTML pages generated by rustdocT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions