diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 39a631b637bd4..a6cf46c50b250 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -479,9 +479,9 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i Some(ty::Visibility::Restricted(_)) => { if myitem.is_doc_hidden() { // Don't separate with a space when there are two of them - " ðŸ”’👻 " + " ðŸ”’👻 " } else { - " ðŸ”’ " + " ðŸ”’ " } } _ if myitem.is_doc_hidden() => { diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index a81d5c9c49b4b..b055a5e3c71d9 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -2891,6 +2891,11 @@ in src-script.js and main.js margin-bottom: 0; } +.hide-priv dt:has(.priv-item), +.hide-priv dt:has(.priv-item) + dd { + display: none; +} + /* End: styles for --scrape-examples feature */ /* Begin: styles for themes diff --git a/src/librustdoc/html/static/js/settings.js b/src/librustdoc/html/static/js/settings.js index 2430b5829b2ba..7ee162a398919 100644 --- a/src/librustdoc/html/static/js/settings.js +++ b/src/librustdoc/html/static/js/settings.js @@ -90,6 +90,8 @@ removeClass(document.documentElement, "word-wrap-source-code"); } break; + case "show-private-items": + showPrivateItems(value === true); } } @@ -286,6 +288,11 @@ "js_name": "word-wrap-source-code", "default": false, }, + { + "name": "Show private items", + "js_name": "show-private-items", + "default": false, + }, ]; // Then we build the DOM. @@ -343,6 +350,19 @@ } } + /** + * @param {boolean} value + */ + function showPrivateItems(value) { + /*document.querySelectorAll("dt:has([title='Restricted Visibility'])").forEach(x => x.hidden = !value); + */ + if (value) { + removeClass(document.documentElement, "hide-priv"); + } else { + addClass(document.documentElement, "hide-priv"); + } + } + if (!isSettingsPage) { // We replace the existing "onclick" callback. // These elements must exist, as (outside of the settings page) diff --git a/src/librustdoc/html/static/js/storage.js b/src/librustdoc/html/static/js/storage.js index 7611372689478..e2f5a8788df8d 100644 --- a/src/librustdoc/html/static/js/storage.js +++ b/src/librustdoc/html/static/js/storage.js @@ -333,6 +333,9 @@ if (getSettingValue("sans-serif-fonts") === "true") { if (getSettingValue("word-wrap-source-code") === "true") { addClass(document.documentElement, "word-wrap-source-code"); } +if (getSettingValue("show-private-items") !== "true") { + addClass(document.documentElement, "hide-priv"); +} function updateSidebarWidth() { const desktopSidebarWidth = getSettingValue("desktop-sidebar-width"); if (desktopSidebarWidth && desktopSidebarWidth !== "null") {