Skip to content

Commit 96c2982

Browse files
* Select the current channel as the default selected version.
* Improve bootstrap source code
1 parent 810dc9b commit 96c2982

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/bootstrap/doc.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,11 @@ impl Step for Std {
430430
t!(fs::create_dir_all(&out));
431431
t!(fs::copy(builder.src.join("src/doc/rust.css"), out.join("rust.css")));
432432

433-
let content = fs::read_to_string(builder.src.join("src/doc/version-switcher.js")).unwrap();
434-
fs::write(
433+
let content = t!(fs::read_to_string(builder.src.join("src/doc/version-switcher.js")));
434+
t!(fs::write(
435435
out.join("version-switcher.js"),
436436
content.replace("/* VERSION TO BE REPLACED */", &builder.version),
437-
)
438-
.unwrap();
437+
));
439438

440439
let index_page = builder.src.join("src/doc/index.md").into_os_string();
441440
let switcher_script = builder.src.join("src/doc/switcher.inc").into_os_string();

src/doc/version-switcher.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const CURRENT_VERSION = "/* VERSION TO BE REPLACED */";
22

33
function checkIfIsOldVersion() {
44
if (["http:", "https:"].indexOf(window.location.protocol) === -1) {
5-
return;
5+
return false;
66
}
77
const parts = window.location.pathname.split("/");
88

@@ -155,9 +155,9 @@ function showSwitcher(isOldVersion) {
155155
const current_doc_version = window.location.pathname.split("/")[1];
156156
const version_picker = document.createElement("select");
157157

158-
version_picker.appendChild(createOption("stable", false));
159-
version_picker.appendChild(createOption("beta", false));
160-
version_picker.appendChild(createOption("nightly", false));
158+
version_picker.appendChild(createOption("stable", current_doc_version === "stable"));
159+
version_picker.appendChild(createOption("beta", current_doc_version === "beta"));
160+
version_picker.appendChild(createOption("nightly", current_doc_version === "nightly"));
161161

162162
const version_parts = CURRENT_VERSION.split(".");
163163
for (let major = parseInt(version_parts[0]); major >= 1; --major) {

0 commit comments

Comments
 (0)