Skip to content

Commit 855a573

Browse files
StupremeeMark-Simulacrum
authored andcommitted
Call initSidebarItems in root module of crate
1 parent ff346b9 commit 855a573

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

src/librustdoc/html/render/mod.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -1724,12 +1724,17 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
17241724
ty = it.type_(),
17251725
path = relpath
17261726
);
1727+
17271728
if parentlen == 0 {
1728-
// There is no sidebar-items.js beyond the crate root path
1729-
// FIXME maybe dynamic crate loading can be merged here
1729+
write!(
1730+
buffer,
1731+
"<script defer src=\"{}sidebar-items{}.js\"></script>",
1732+
relpath, cx.shared.resource_suffix
1733+
);
17301734
} else {
1731-
write!(buffer, "<script defer src=\"{path}sidebar-items.js\"></script>", path = relpath);
1735+
write!(buffer, "<script defer src=\"{}sidebar-items.js\"></script>", relpath);
17321736
}
1737+
17331738
// Closes sidebar-elems div.
17341739
buffer.write_str("</div>");
17351740
}

src/librustdoc/html/render/write_shared.rs

+2
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ pub(super) fn write_shared(
224224
)?;
225225
write_minify("search.js", static_files::SEARCH_JS)?;
226226
write_minify("settings.js", static_files::SETTINGS_JS)?;
227+
write_minify("sidebar-items.js", static_files::sidebar::ITEMS)?;
228+
227229
if cx.shared.include_sources {
228230
write_minify("source-script.js", static_files::sidebar::SOURCE_SCRIPT)?;
229231
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
initSidebarItems({});

src/librustdoc/html/static_files.rs

+3
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,7 @@ crate mod source_code_pro {
127127
crate mod sidebar {
128128
/// File script to handle sidebar.
129129
crate static SOURCE_SCRIPT: &str = include_str!("static/source-script.js");
130+
131+
/// Top Level sidebar items script which will load a sidebar without items.
132+
crate static ITEMS: &str = include_str!("static/sidebar-items.js");
130133
}

0 commit comments

Comments
 (0)