Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
* Select the current channel as the default selected version.
* Improve bootstrap source code
  • Loading branch information
GuillaumeGomez committed Sep 27, 2022
commit 96c298246778c6dc17af6a5af3bd6edef7b9c1af
7 changes: 3 additions & 4 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,11 @@ impl Step for Std {
t!(fs::create_dir_all(&out));
t!(fs::copy(builder.src.join("src/doc/rust.css"), out.join("rust.css")));

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

let index_page = builder.src.join("src/doc/index.md").into_os_string();
let switcher_script = builder.src.join("src/doc/switcher.inc").into_os_string();
Expand Down
8 changes: 4 additions & 4 deletions src/doc/version-switcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const CURRENT_VERSION = "/* VERSION TO BE REPLACED */";

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

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

version_picker.appendChild(createOption("stable", false));
version_picker.appendChild(createOption("beta", false));
version_picker.appendChild(createOption("nightly", false));
version_picker.appendChild(createOption("stable", current_doc_version === "stable"));
version_picker.appendChild(createOption("beta", current_doc_version === "beta"));
version_picker.appendChild(createOption("nightly", current_doc_version === "nightly"));

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