Auto merge of #110076 - Nilstrieb:rollup-22yp01c, r=Nilstrieb
Rollup of 5 pull requests Successful merges: - #110030 (rustdoc: clean up JS) - #110037 (rustdoc: add test and bug fix for theme defaults) - #110065 (Fix wrong type in docs: i16 -> u16) - #110068 (Temporarily remove myself from reviewers list) - #110075 (Fix a typo in `config.example.toml`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@
|
||||
# Use different pre-set defaults than the global defaults.
|
||||
#
|
||||
# See `src/bootstrap/defaults` for more information.
|
||||
# Note that this has no default value (x.py uses the defaults in `config.toml.example`).
|
||||
# Note that this has no default value (x.py uses the defaults in `config.example.toml`).
|
||||
#profile = <none>
|
||||
|
||||
# Keeps track of the last version of `x.py` used.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Redundant constants module for the [`i16` primitive type][i16].
|
||||
//! Redundant constants module for the [`u16` primitive type][u16].
|
||||
//!
|
||||
//! New code should use the associated constants directly on the primitive type.
|
||||
|
||||
|
||||
@@ -332,13 +332,7 @@ function preLoadCss(cssUrl) {
|
||||
};
|
||||
|
||||
function getPageId() {
|
||||
if (window.location.hash) {
|
||||
const tmp = window.location.hash.replace(/^#/, "");
|
||||
if (tmp.length > 0) {
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return window.location.hash.replace(/^#/, "");
|
||||
}
|
||||
|
||||
const toggleAllDocsId = "toggle-all-docs";
|
||||
@@ -707,7 +701,7 @@ function preLoadCss(cssUrl) {
|
||||
});
|
||||
|
||||
const pageId = getPageId();
|
||||
if (pageId !== null) {
|
||||
if (pageId !== "") {
|
||||
expandSection(pageId);
|
||||
}
|
||||
}());
|
||||
|
||||
@@ -86,12 +86,8 @@
|
||||
if (settingId === "theme") {
|
||||
const useSystem = getSettingValue("use-system-theme");
|
||||
if (useSystem === "true" || settingValue === null) {
|
||||
if (useSystem !== "false") {
|
||||
settingValue = "system preference";
|
||||
} else {
|
||||
// This is the default theme.
|
||||
settingValue = "light";
|
||||
}
|
||||
// "light" is the default theme
|
||||
settingValue = useSystem === "false" ? "light" : "system preference";
|
||||
}
|
||||
}
|
||||
if (settingValue !== null && settingValue !== "null") {
|
||||
|
||||
@@ -53,10 +53,9 @@ function removeClass(elem, className) {
|
||||
* @param {boolean} [reversed] - Whether to iterate in reverse
|
||||
*/
|
||||
function onEach(arr, func, reversed) {
|
||||
if (arr && arr.length > 0 && func) {
|
||||
if (arr && arr.length > 0) {
|
||||
if (reversed) {
|
||||
const length = arr.length;
|
||||
for (let i = length - 1; i >= 0; --i) {
|
||||
for (let i = arr.length - 1; i >= 0; --i) {
|
||||
if (func(arr[i])) {
|
||||
return true;
|
||||
}
|
||||
@@ -150,26 +149,19 @@ const updateTheme = (function() {
|
||||
* … dictates that it should be.
|
||||
*/
|
||||
function updateTheme() {
|
||||
const use = (theme, saveTheme) => {
|
||||
switchTheme(theme, saveTheme);
|
||||
};
|
||||
|
||||
// maybe the user has disabled the setting in the meantime!
|
||||
if (getSettingValue("use-system-theme") !== "false") {
|
||||
const lightTheme = getSettingValue("preferred-light-theme") || "light";
|
||||
const darkTheme = getSettingValue("preferred-dark-theme") || "dark";
|
||||
updateLocalStorage("use-system-theme", "true");
|
||||
|
||||
if (mql.matches) {
|
||||
use(darkTheme, true);
|
||||
} else {
|
||||
// prefers a light theme, or has no preference
|
||||
use(lightTheme, true);
|
||||
}
|
||||
// use light theme if user prefers it, or has no preference
|
||||
switchTheme(mql.matches ? darkTheme : lightTheme, true);
|
||||
// note: we save the theme so that it doesn't suddenly change when
|
||||
// the user disables "use-system-theme" and reloads the page or
|
||||
// navigates to another page
|
||||
} else {
|
||||
use(getSettingValue("theme"), false);
|
||||
switchTheme(getSettingValue("theme"), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// Ensure that the theme picker always starts with the actual defaults.
|
||||
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
||||
click: "#settings-menu"
|
||||
wait-for: "#theme-system-preference"
|
||||
assert: "#theme-system-preference:checked"
|
||||
assert: "#preferred-light-theme-light:checked"
|
||||
assert: "#preferred-dark-theme-dark:checked"
|
||||
assert-false: "#preferred-dark-theme-ayu:checked"
|
||||
|
||||
// Test legacy migration from old theme setup without system-preference matching.
|
||||
// See https://github.com/rust-lang/rust/pull/77809#issuecomment-707875732
|
||||
local-storage: {
|
||||
"rustdoc-preferred-light-theme": null,
|
||||
"rustdoc-preferred-dark-theme": null,
|
||||
"rustdoc-use-system-theme": null,
|
||||
"rustdoc-theme": "ayu"
|
||||
}
|
||||
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
||||
click: "#settings-menu"
|
||||
wait-for: "#theme-system-preference"
|
||||
assert: "#theme-system-preference:checked"
|
||||
assert: "#preferred-light-theme-light:checked"
|
||||
assert-false: "#preferred-dark-theme-dark:checked"
|
||||
assert: "#preferred-dark-theme-ayu:checked"
|
||||
+2
-3
@@ -470,8 +470,8 @@ cc = ["@rust-lang/style"]
|
||||
|
||||
[mentions."Cargo.lock"]
|
||||
message = """
|
||||
These commits modify the `Cargo.lock` file. Random changes to `Cargo.lock` can be introduced when switching branches and rebasing PRs.
|
||||
This was probably unintentional and should be reverted before this PR is merged.
|
||||
These commits modify the `Cargo.lock` file. Random changes to `Cargo.lock` can be introduced when switching branches and rebasing PRs.
|
||||
This was probably unintentional and should be reverted before this PR is merged.
|
||||
|
||||
If this was intentional then you can ignore this comment.
|
||||
"""
|
||||
@@ -499,7 +499,6 @@ compiler-team = [
|
||||
]
|
||||
compiler-team-contributors = [
|
||||
"@compiler-errors",
|
||||
"@eholk",
|
||||
"@jackh726",
|
||||
"@TaKO8Ki",
|
||||
"@WaffleLapkin",
|
||||
|
||||
Reference in New Issue
Block a user