Call initSidebarItems
in root module of crate
This commit is contained in:
parent
75da570d78
commit
aaf0ff83fb
4 changed files with 14 additions and 3 deletions
|
@ -1745,12 +1745,17 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
|
||||||
ty = it.type_(),
|
ty = it.type_(),
|
||||||
path = relpath
|
path = relpath
|
||||||
);
|
);
|
||||||
|
|
||||||
if parentlen == 0 {
|
if parentlen == 0 {
|
||||||
// There is no sidebar-items.js beyond the crate root path
|
write!(
|
||||||
// FIXME maybe dynamic crate loading can be merged here
|
buffer,
|
||||||
|
"<script defer src=\"{}sidebar-items{}.js\"></script>",
|
||||||
|
relpath, cx.shared.resource_suffix
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
write!(buffer, "<script defer src=\"{path}sidebar-items.js\"></script>", path = relpath);
|
write!(buffer, "<script defer src=\"{}sidebar-items.js\"></script>", relpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Closes sidebar-elems div.
|
// Closes sidebar-elems div.
|
||||||
buffer.write_str("</div>");
|
buffer.write_str("</div>");
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,6 +225,8 @@ pub(super) fn write_shared(
|
||||||
)?;
|
)?;
|
||||||
write_minify("search.js", static_files::SEARCH_JS)?;
|
write_minify("search.js", static_files::SEARCH_JS)?;
|
||||||
write_minify("settings.js", static_files::SETTINGS_JS)?;
|
write_minify("settings.js", static_files::SETTINGS_JS)?;
|
||||||
|
write_minify("sidebar-items.js", static_files::sidebar::ITEMS)?;
|
||||||
|
|
||||||
if cx.shared.include_sources {
|
if cx.shared.include_sources {
|
||||||
write_minify("source-script.js", static_files::sidebar::SOURCE_SCRIPT)?;
|
write_minify("source-script.js", static_files::sidebar::SOURCE_SCRIPT)?;
|
||||||
}
|
}
|
||||||
|
|
1
src/librustdoc/html/static/sidebar-items.js
Normal file
1
src/librustdoc/html/static/sidebar-items.js
Normal file
|
@ -0,0 +1 @@
|
||||||
|
initSidebarItems({});
|
|
@ -130,4 +130,7 @@ crate mod source_code_pro {
|
||||||
crate mod sidebar {
|
crate mod sidebar {
|
||||||
/// File script to handle sidebar.
|
/// File script to handle sidebar.
|
||||||
crate static SOURCE_SCRIPT: &str = include_str!("static/source-script.js");
|
crate static SOURCE_SCRIPT: &str = include_str!("static/source-script.js");
|
||||||
|
|
||||||
|
/// Top Level sidebar items script which will load a sidebar without items.
|
||||||
|
crate static ITEMS: &str = include_str!("static/sidebar-items.js");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue