Skip to content

Commit 5c8c4db

Browse files
authored
Rollup merge of rust-lang#99209 - GuillaumeGomez:crate-level-sidebar, r=jsha
Correctly handle crate level page on docs.rs as well Fixes rust-lang#99121. On docs.rs, they move the `class` attribute into a child which still has `rustdoc`. So instead of using the `<body>`, we can simply use this one directly. r? `@jsha`
2 parents 24f0e14 + b98fb49 commit 5c8c4db

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

src/librustdoc/html/static/js/main.js

+14-17
Original file line numberDiff line numberDiff line change
@@ -479,23 +479,20 @@ function loadCss(cssFileName) {
479479
}
480480

481481
if (sidebar) {
482-
const isModule = hasClass(document.body, "mod");
483-
if (!isModule) {
484-
block("primitive", "primitives", "Primitive Types");
485-
block("mod", "modules", "Modules");
486-
block("macro", "macros", "Macros");
487-
block("struct", "structs", "Structs");
488-
block("enum", "enums", "Enums");
489-
block("union", "unions", "Unions");
490-
block("constant", "constants", "Constants");
491-
block("static", "static", "Statics");
492-
block("trait", "traits", "Traits");
493-
block("fn", "functions", "Functions");
494-
block("type", "types", "Type Definitions");
495-
block("foreigntype", "foreign-types", "Foreign Types");
496-
block("keyword", "keywords", "Keywords");
497-
block("traitalias", "trait-aliases", "Trait Aliases");
498-
}
482+
block("primitive", "primitives", "Primitive Types");
483+
block("mod", "modules", "Modules");
484+
block("macro", "macros", "Macros");
485+
block("struct", "structs", "Structs");
486+
block("enum", "enums", "Enums");
487+
block("union", "unions", "Unions");
488+
block("constant", "constants", "Constants");
489+
block("static", "static", "Statics");
490+
block("trait", "traits", "Traits");
491+
block("fn", "functions", "Functions");
492+
block("type", "types", "Type Definitions");
493+
block("foreigntype", "foreign-types", "Foreign Types");
494+
block("keyword", "keywords", "Keywords");
495+
block("traitalias", "trait-aliases", "Trait Aliases");
499496
}
500497
}
501498

src/librustdoc/html/templates/page.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
{%- else if page.css_class == "source" -%}
4040
<script defer src="{{static_root_path|safe}}source-script{{page.resource_suffix}}.js"></script> {#- -#}
4141
<script defer src="{{page.root_path|safe}}source-files{{page.resource_suffix}}.js"></script> {#- -#}
42-
{%- else -%}
42+
{%- else if !page.css_class.contains("mod") -%}
4343
<script defer src="sidebar-items{{page.resource_suffix}}.js"></script> {#- -#}
4444
{%- endif -%}
4545
<script defer src="{{static_root_path|safe}}main{{page.resource_suffix}}.js"></script> {#- -#}

0 commit comments

Comments
 (0)