rustdoc: add missing macros to sibling nav sidebar

This commit is contained in:
Michael Howell 2023-09-23 14:05:16 -07:00
parent 47c46324aa
commit 7bb2c96c69
3 changed files with 21 additions and 8 deletions

View File

@ -2079,6 +2079,7 @@ impl ItemSection {
const ALL: &'static [Self] = { const ALL: &'static [Self] = {
use ItemSection::*; use ItemSection::*;
// NOTE: The order here affects the order in the UI. // NOTE: The order here affects the order in the UI.
// Keep this synchronized with addSidebarItems in main.js
&[ &[
Reexports, Reexports,
PrimitiveTypes, PrimitiveTypes,

View File

@ -119,18 +119,16 @@ pub(super) fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buf
// //
// otherwise, the parent path header is redundant with the big crate // otherwise, the parent path header is redundant with the big crate
// branding area at the top of the sidebar // branding area at the top of the sidebar
let sidebar_path = if it.is_mod() { &cx.current[..cx.current.len() - 1] } else { &cx.current[..] }; let sidebar_path =
if it.is_mod() { &cx.current[..cx.current.len() - 1] } else { &cx.current[..] };
let path: String = if sidebar_path.len() > 1 || !title.is_empty() { let path: String = if sidebar_path.len() > 1 || !title.is_empty() {
let path = sidebar_path.iter().map(|s| s.as_str()).intersperse("::").collect(); let path = sidebar_path.iter().map(|s| s.as_str()).intersperse("::").collect();
if sidebar_path.len() == 1 { if sidebar_path.len() == 1 { format!("crate {path}") } else { path }
format!("crate {path}")
} else {
path
}
} else { } else {
"".into() "".into()
}; };
let sidebar = Sidebar { title_prefix, title, is_mod: it.is_mod(), is_crate: it.is_crate(), blocks, path }; let sidebar =
Sidebar { title_prefix, title, is_mod: it.is_mod(), is_crate: it.is_crate(), blocks, path };
sidebar.render_into(buffer).unwrap(); sidebar.render_into(buffer).unwrap();
} }

View File

@ -490,19 +490,33 @@ function preLoadCss(cssUrl) {
} }
if (sidebar) { if (sidebar) {
// keep this synchronized with ItemSection::ALL in html/render/mod.rs
// Re-exports aren't shown here, because they don't have child pages
//block("reexport", "reexports", "Re-exports");
block("primitive", "primitives", "Primitive Types"); block("primitive", "primitives", "Primitive Types");
block("mod", "modules", "Modules"); block("mod", "modules", "Modules");
block("macro", "macros", "Macros"); block("macro", "macros", "Macros");
block("struct", "structs", "Structs"); block("struct", "structs", "Structs");
block("enum", "enums", "Enums"); block("enum", "enums", "Enums");
block("union", "unions", "Unions");
block("constant", "constants", "Constants"); block("constant", "constants", "Constants");
block("static", "static", "Statics"); block("static", "static", "Statics");
block("trait", "traits", "Traits"); block("trait", "traits", "Traits");
block("fn", "functions", "Functions"); block("fn", "functions", "Functions");
block("type", "types", "Type Aliases"); block("type", "types", "Type Aliases");
block("union", "unions", "Unions");
// No point, because these items don't appear in modules
//block("impl", "impls", "Implementations");
//block("tymethod", "tymethods", "Type Methods");
//block("method", "methods", "Methods");
//block("structfield", "fields", "Fields");
//block("variant", "variants", "Variants");
//block("associatedtype", "associated-types", "Associated Types");
//block("associatedconstant", "associated-consts", "Associated Constants");
block("foreigntype", "foreign-types", "Foreign Types"); block("foreigntype", "foreign-types", "Foreign Types");
block("keyword", "keywords", "Keywords"); block("keyword", "keywords", "Keywords");
block("opaque", "opaque-types", "Opaque Types");
block("attr", "attributes", "Attribute Macros");
block("derive", "derives", "Derive Macros");
block("traitalias", "trait-aliases", "Trait Aliases"); block("traitalias", "trait-aliases", "Trait Aliases");
} }
} }