Skip to content

Commit

Permalink
Correctly handle crate level page on docs.rs as well
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jul 14, 2022
1 parent b3f4c31 commit b98fb49
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
31 changes: 14 additions & 17 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,23 +479,20 @@ function loadCss(cssFileName) {
}

if (sidebar) {
const isModule = hasClass(document.body, "mod");
if (!isModule) {
block("primitive", "primitives", "Primitive Types");
block("mod", "modules", "Modules");
block("macro", "macros", "Macros");
block("struct", "structs", "Structs");
block("enum", "enums", "Enums");
block("union", "unions", "Unions");
block("constant", "constants", "Constants");
block("static", "static", "Statics");
block("trait", "traits", "Traits");
block("fn", "functions", "Functions");
block("type", "types", "Type Definitions");
block("foreigntype", "foreign-types", "Foreign Types");
block("keyword", "keywords", "Keywords");
block("traitalias", "trait-aliases", "Trait Aliases");
}
block("primitive", "primitives", "Primitive Types");
block("mod", "modules", "Modules");
block("macro", "macros", "Macros");
block("struct", "structs", "Structs");
block("enum", "enums", "Enums");
block("union", "unions", "Unions");
block("constant", "constants", "Constants");
block("static", "static", "Statics");
block("trait", "traits", "Traits");
block("fn", "functions", "Functions");
block("type", "types", "Type Definitions");
block("foreigntype", "foreign-types", "Foreign Types");
block("keyword", "keywords", "Keywords");
block("traitalias", "trait-aliases", "Trait Aliases");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{%- else if page.css_class == "source" -%}
<script defer src="{{static_root_path|safe}}source-script{{page.resource_suffix}}.js"></script> {#- -#}
<script defer src="{{page.root_path|safe}}source-files{{page.resource_suffix}}.js"></script> {#- -#}
{%- else -%}
{%- else if !page.css_class.contains("mod") -%}
<script defer src="sidebar-items{{page.resource_suffix}}.js"></script> {#- -#}
{%- endif -%}
<script defer src="{{static_root_path|safe}}main{{page.resource_suffix}}.js"></script> {#- -#}
Expand Down

0 comments on commit b98fb49

Please sign in to comment.