Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
59d4bae
Add validation for `link` attribute position.
ehuss Jan 9, 2022
b59e743
Mark windows_subsytem and no_builtins as crate-only attributes.
ehuss Jan 9, 2022
012910d
Canonicalize const variables correctly
compiler-errors Jan 7, 2022
9bf9fe0
Don't leak inference variables in array unsizing
compiler-errors Jan 7, 2022
7bf0cb7
Add new tests, fix up old tests
compiler-errors Jan 7, 2022
a7092f9
Typos fix
maxwase Jan 13, 2022
5431d5b
Add rustc_diagnostic_item attribute to AtomicBool
llogiq Jan 13, 2022
c4b994f
Pick themes on settings page, not every page
jsha Jan 6, 2022
04f0402
Add support for "always theme" in setting
jsha Jan 7, 2022
9c6d8ef
htmldocck: Add support for `/text()` in `@snapshot`
camelid Jan 15, 2022
1a37262
Exclude llvm-libunwind from the self-contained set on s390x-musl targ…
kaniini Jan 15, 2022
47de5b4
Remove `collect`
vacuus Jan 15, 2022
e6aef25
Add `~const` bound test for negative impls
lilasta Jan 17, 2022
853feb6
update codegen test for LLVM 14
Jan 17, 2022
e4607ff
update test assertion
Jan 17, 2022
43b9268
Rustdoc style cleanups
jsha Jan 12, 2022
b71f1fb
Hide mobile sidebar on some clicks
jsha Jan 12, 2022
7b5b3cf
Abstract the pretty printer's ringbuffer to be infinitely sized
dtolnay Jan 15, 2022
e012b9a
Stabilize vec_spare_capacity
Amanieu Jan 17, 2022
ae99e23
Add staged_api for tests
jsha Jan 15, 2022
d501ead
Rollup merge of #92629 - jsha:theme-picker-local-only-2, r=GuillaumeG…
matthiaskrgr Jan 18, 2022
cb5ecff
Rollup merge of #92640 - compiler-errors:array-deref-on-newtype, r=lcnr
matthiaskrgr Jan 18, 2022
804072f
Rollup merge of #92701 - ehuss:even-more-attr-validation, r=matthewja…
matthiaskrgr Jan 18, 2022
cc2339c
Rollup merge of #92803 - jsha:hide-sidebar, r=GuillaumeGomez
matthiaskrgr Jan 18, 2022
deee6f7
Rollup merge of #92830 - jsha:style-cleanups, r=GuillaumeGomez
matthiaskrgr Jan 18, 2022
ae8f39e
Rollup merge of #92866 - maxwase:does_exist_typo, r=Mark-Simulacrum
matthiaskrgr Jan 18, 2022
6a5663e
Rollup merge of #92870 - llogiq:atomic_bool_sym, r=Manishearth
matthiaskrgr Jan 18, 2022
be3d25b
Rollup merge of #92914 - camelid:snapshot-text, r=GuillaumeGomez
matthiaskrgr Jan 18, 2022
04b2073
Rollup merge of #92923 - dtolnay:ringbuffer, r=petrochenkov
matthiaskrgr Jan 18, 2022
b05be97
Rollup merge of #92946 - kaniini:chore/llvm-libunwind-s390x, r=Mark-S…
matthiaskrgr Jan 18, 2022
71e5bfe
Rollup merge of #92947 - vacuus:rustdoc-core-visit-path, r=camelid
matthiaskrgr Jan 18, 2022
baeff67
Rollup merge of #92997 - woppopo:test92114, r=Mark-Simulacrum
matthiaskrgr Jan 18, 2022
b8c544d
Rollup merge of #93004 - krasimirgg:threadlocal-llvm-up, r=nikic
matthiaskrgr Jan 18, 2022
83b1a94
Rollup merge of #93016 - Amanieu:vec_spare_capacity, r=Mark-Simulacrum
matthiaskrgr Jan 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,12 @@ fn settings(root_path: &str, suffix: &str, theme_names: Vec<String>) -> Result<S
"Theme preferences",
vec![
Setting::from(("use-system-theme", "Use system theme", true)),
Setting::Select {
js_data_name: "theme",
description: "Theme",
default_value: "light",
options: theme_names.clone(),
},
Setting::Select {
js_data_name: "preferred-dark-theme",
description: "Preferred dark theme",
Expand Down
17 changes: 6 additions & 11 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,12 @@ details.rustdoc-toggle[open] > summary.hideme::after {
padding-top: 0px;
}

/* Space is at a premium on mobile, so remove the theme-picker icon. */
#theme-picker {
display: none;
width: 0;
}

.rustdoc {
flex-direction: column;
}
Expand Down Expand Up @@ -1884,12 +1890,6 @@ details.rustdoc-toggle[open] > summary.hideme::after {
height: 100%;
}

nav.sub {
width: calc(100% - 32px);
margin-left: 32px;
margin-bottom: 10px;
}

.source nav:not(.sidebar).sub {
margin-left: 32px;
}
Expand Down Expand Up @@ -2086,11 +2086,6 @@ details.rustdoc-toggle[open] > summary.hideme::after {
border: 0;
}

#crate-search + .search-input {
width: calc(100% + 71px);
margin-left: -36px;
}

#theme-picker, #settings-menu {
padding: 5px;
width: 31px;
Expand Down
5 changes: 5 additions & 0 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,15 @@ function hideThemeButtonState() {

// Set up the theme picker list.
(function () {
if (!document.location.href.startsWith("file:///")) {
return;
}
var themeChoices = getThemesElement();
var themePicker = getThemePickerElement();
var availableThemes = getVar("themes").split(",");

removeClass(themeChoices.parentElement, "hidden");

function switchThemeButtonState() {
if (themeChoices.style.display === "block") {
hideThemeButtonState();
Expand Down
28 changes: 28 additions & 0 deletions src/librustdoc/html/static/js/settings.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
// Local js definitions:
/* global getSettingValue, getVirtualKey, onEachLazy, updateLocalStorage, updateSystemTheme */
/* global addClass, removeClass */

(function () {
function changeSetting(settingName, value) {
updateLocalStorage("rustdoc-" + settingName, value);

switch (settingName) {
case "theme":
case "preferred-dark-theme":
case "preferred-light-theme":
case "use-system-theme":
updateSystemTheme();
updateLightAndDark();
break;
}
}
Expand All @@ -29,7 +32,32 @@
}
}

function showLightAndDark() {
addClass(document.getElementById("theme").parentElement.parentElement, "hidden");
removeClass(document.getElementById("preferred-light-theme").parentElement.parentElement,
"hidden");
removeClass(document.getElementById("preferred-dark-theme").parentElement.parentElement,
"hidden");
}

function hideLightAndDark() {
addClass(document.getElementById("preferred-light-theme").parentElement.parentElement,
"hidden");
addClass(document.getElementById("preferred-dark-theme").parentElement.parentElement,
"hidden");
removeClass(document.getElementById("theme").parentElement.parentElement, "hidden");
}

function updateLightAndDark() {
if (getSettingValue("use-system-theme") !== "false") {
showLightAndDark();
} else {
hideLightAndDark();
}
}

function setEvents() {
updateLightAndDark();
onEachLazy(document.getElementsByClassName("slider"), function(elem) {
var toggle = elem.previousElementSibling;
var settingId = toggle.id;
Expand Down
11 changes: 7 additions & 4 deletions src/librustdoc/html/static/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,22 +187,25 @@ var updateSystemTheme = (function() {
var mql = window.matchMedia("(prefers-color-scheme: dark)");

function handlePreferenceChange(mql) {
let use = function(theme) {
switchTheme(window.currentTheme, window.mainTheme, theme, true);
};
// maybe the user has disabled the setting in the meantime!
if (getSettingValue("use-system-theme") !== "false") {
var lightTheme = getSettingValue("preferred-light-theme") || "light";
var darkTheme = getSettingValue("preferred-dark-theme") || "dark";

if (mql.matches) {
// prefers a dark theme
switchTheme(window.currentTheme, window.mainTheme, darkTheme, true);
use(darkTheme);
} else {
// prefers a light theme, or has no preference
switchTheme(window.currentTheme, window.mainTheme, lightTheme, true);
use(lightTheme);
}

// 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"));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
{%- endif -%}
</a> {#- -#}
<nav class="sub"> {#- -#}
<div class="theme-picker"> {#- -#}
<div class="theme-picker hidden"> {#- -#}
<button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"> {#- -#}
<img width="18" height="18" alt="Pick another theme!" {# -#}
src="{{static_root_path|safe}}brush{{page.resource_suffix}}.svg"> {#- -#}
Expand Down
12 changes: 6 additions & 6 deletions src/test/rustdoc-gui/toggle-docs-mobile.goml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
goto: file://|DOC_PATH|/test_docs/struct.Foo.html
size: (433, 600)
assert-attribute: (".top-doc", {"open": ""})
click: (4, 240) // This is the position of the top doc comment toggle
click: (4, 260) // This is the position of the top doc comment toggle
assert-attribute-false: (".top-doc", {"open": ""})
click: (4, 240)
click: (4, 260)
assert-attribute: (".top-doc", {"open": ""})
// To ensure that the toggle isn't over the text, we check that the toggle isn't clicked.
click: (3, 240)
click: (3, 260)
assert-attribute: (".top-doc", {"open": ""})

// Assert the position of the toggle on the top doc block.
Expand All @@ -22,10 +22,10 @@ assert-position: (
// Now we do the same but with a little bigger width
size: (600, 600)
assert-attribute: (".top-doc", {"open": ""})
click: (4, 240) // New Y position since all search elements are back on one line.
click: (4, 260) // New Y position since all search elements are back on one line.
assert-attribute-false: (".top-doc", {"open": ""})
click: (4, 240)
click: (4, 260)
assert-attribute: (".top-doc", {"open": ""})
// To ensure that the toggle isn't over the text, we check that the toggle isn't clicked.
click: (3, 240)
click: (3, 260)
assert-attribute: (".top-doc", {"open": ""})