`) of items.
@@ -878,7 +878,7 @@ function preLoadCss(cssUrl) {
if (!window.ALL_CRATES) {
return;
}
- const sidebarElems = document.getElementsByClassName("sidebar-elems")[0];
+ const sidebarElems = document.getElementById("ModNav");
if (!sidebarElems) {
return;
}
diff --git a/src/librustdoc/html/static/js/settings.js b/src/librustdoc/html/static/js/settings.js
index 2b42fbebb803d..c52a19ef98738 100644
--- a/src/librustdoc/html/static/js/settings.js
+++ b/src/librustdoc/html/static/js/settings.js
@@ -36,6 +36,20 @@
removeClass(document.documentElement, "hide-sidebar");
}
break;
+ case "hide-toc":
+ if (value === true) {
+ addClass(document.documentElement, "hide-toc");
+ } else {
+ removeClass(document.documentElement, "hide-toc");
+ }
+ break;
+ case "hide-modnav":
+ if (value === true) {
+ addClass(document.documentElement, "hide-modnav");
+ } else {
+ removeClass(document.documentElement, "hide-modnav");
+ }
+ break;
}
}
@@ -102,6 +116,11 @@
let output = "";
for (const setting of settings) {
+ if (setting === "hr") {
+ output += "";
+ continue;
+ }
+
const js_data_name = setting["js_name"];
const setting_name = setting["name"];
@@ -198,6 +217,16 @@
"js_name": "hide-sidebar",
"default": false,
},
+ {
+ "name": "Hide table of contents",
+ "js_name": "hide-toc",
+ "default": false,
+ },
+ {
+ "name": "Hide module navigation",
+ "js_name": "hide-modnav",
+ "default": false,
+ },
{
"name": "Disable keyboard shortcuts",
"js_name": "disable-shortcuts",
diff --git a/src/librustdoc/html/static/js/storage.js b/src/librustdoc/html/static/js/storage.js
index 4a27ca92fff38..d75fb7a7fb5ab 100644
--- a/src/librustdoc/html/static/js/storage.js
+++ b/src/librustdoc/html/static/js/storage.js
@@ -196,16 +196,21 @@ updateTheme();
// This needs to be done here because this JS is render-blocking,
// so that the sidebar doesn't "jump" after appearing on screen.
// The user interaction to change this is set up in main.js.
+//
+// At this point in page load, `document.body` is not available yet.
+// Set a class on the `` element instead.
if (getSettingValue("source-sidebar-show") === "true") {
- // At this point in page load, `document.body` is not available yet.
- // Set a class on the `` element instead.
addClass(document.documentElement, "src-sidebar-expanded");
}
if (getSettingValue("hide-sidebar") === "true") {
- // At this point in page load, `document.body` is not available yet.
- // Set a class on the `` element instead.
addClass(document.documentElement, "hide-sidebar");
}
+if (getSettingValue("hide-toc") === "true") {
+ addClass(document.documentElement, "hide-toc");
+}
+if (getSettingValue("hide-modnav") === "true") {
+ addClass(document.documentElement, "hide-modnav");
+}
function updateSidebarWidth() {
const desktopSidebarWidth = getSettingValue("desktop-sidebar-width");
if (desktopSidebarWidth && desktopSidebarWidth !== "null") {
diff --git a/src/librustdoc/html/templates/sidebar.html b/src/librustdoc/html/templates/sidebar.html
index 468018a0d2176..3d7bb592ab016 100644
--- a/src/librustdoc/html/templates/sidebar.html
+++ b/src/librustdoc/html/templates/sidebar.html
@@ -1,8 +1,3 @@
-{% if !title.is_empty() %}
-