Skip to content

Commit 7bb2c96

Browse files
committed
rustdoc: add missing macros to sibling nav sidebar
1 parent 47c4632 commit 7bb2c96

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

src/librustdoc/html/render/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2079,6 +2079,7 @@ impl ItemSection {
20792079
const ALL: &'static [Self] = {
20802080
use ItemSection::*;
20812081
// NOTE: The order here affects the order in the UI.
2082+
// Keep this synchronized with addSidebarItems in main.js
20822083
&[
20832084
Reexports,
20842085
PrimitiveTypes,

src/librustdoc/html/render/sidebar.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,16 @@ pub(super) fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buf
119119
//
120120
// otherwise, the parent path header is redundant with the big crate
121121
// branding area at the top of the sidebar
122-
let sidebar_path = if it.is_mod() { &cx.current[..cx.current.len() - 1] } else { &cx.current[..] };
122+
let sidebar_path =
123+
if it.is_mod() { &cx.current[..cx.current.len() - 1] } else { &cx.current[..] };
123124
let path: String = if sidebar_path.len() > 1 || !title.is_empty() {
124125
let path = sidebar_path.iter().map(|s| s.as_str()).intersperse("::").collect();
125-
if sidebar_path.len() == 1 {
126-
format!("crate {path}")
127-
} else {
128-
path
129-
}
126+
if sidebar_path.len() == 1 { format!("crate {path}") } else { path }
130127
} else {
131128
"".into()
132129
};
133-
let sidebar = Sidebar { title_prefix, title, is_mod: it.is_mod(), is_crate: it.is_crate(), blocks, path };
130+
let sidebar =
131+
Sidebar { title_prefix, title, is_mod: it.is_mod(), is_crate: it.is_crate(), blocks, path };
134132
sidebar.render_into(buffer).unwrap();
135133
}
136134

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

+15-1
Original file line numberDiff line numberDiff line change
@@ -490,19 +490,33 @@ function preLoadCss(cssUrl) {
490490
}
491491

492492
if (sidebar) {
493+
// keep this synchronized with ItemSection::ALL in html/render/mod.rs
494+
// Re-exports aren't shown here, because they don't have child pages
495+
//block("reexport", "reexports", "Re-exports");
493496
block("primitive", "primitives", "Primitive Types");
494497
block("mod", "modules", "Modules");
495498
block("macro", "macros", "Macros");
496499
block("struct", "structs", "Structs");
497500
block("enum", "enums", "Enums");
498-
block("union", "unions", "Unions");
499501
block("constant", "constants", "Constants");
500502
block("static", "static", "Statics");
501503
block("trait", "traits", "Traits");
502504
block("fn", "functions", "Functions");
503505
block("type", "types", "Type Aliases");
506+
block("union", "unions", "Unions");
507+
// No point, because these items don't appear in modules
508+
//block("impl", "impls", "Implementations");
509+
//block("tymethod", "tymethods", "Type Methods");
510+
//block("method", "methods", "Methods");
511+
//block("structfield", "fields", "Fields");
512+
//block("variant", "variants", "Variants");
513+
//block("associatedtype", "associated-types", "Associated Types");
514+
//block("associatedconstant", "associated-consts", "Associated Constants");
504515
block("foreigntype", "foreign-types", "Foreign Types");
505516
block("keyword", "keywords", "Keywords");
517+
block("opaque", "opaque-types", "Opaque Types");
518+
block("attr", "attributes", "Attribute Macros");
519+
block("derive", "derives", "Derive Macros");
506520
block("traitalias", "trait-aliases", "Trait Aliases");
507521
}
508522
}

0 commit comments

Comments
 (0)