@@ -1713,7 +1713,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
1713
1713
"<div class=\" block version\" >\
1714
1714
<p>Version {}</p>\
1715
1715
</div>",
1716
- Escape ( version)
1716
+ Escape ( version) ,
1717
1717
) ;
1718
1718
}
1719
1719
}
@@ -1723,9 +1723,10 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
1723
1723
write ! (
1724
1724
buffer,
1725
1725
"<a id=\" all-types\" href=\" all.html\" ><p>See all {}'s items</p></a>" ,
1726
- it. name. as_ref( ) . expect( "crates always have a name" )
1726
+ it. name. as_ref( ) . expect( "crates always have a name" ) ,
1727
1727
) ;
1728
1728
}
1729
+
1729
1730
match * it. kind {
1730
1731
clean:: StructItem ( ref s) => sidebar_struct ( cx, buffer, it, s) ,
1731
1732
clean:: TraitItem ( ref t) => sidebar_trait ( cx, buffer, it, t) ,
@@ -1735,7 +1736,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
1735
1736
clean:: TypedefItem ( _, _) => sidebar_typedef ( cx, buffer, it) ,
1736
1737
clean:: ModuleItem ( ref m) => sidebar_module ( buffer, & m. items ) ,
1737
1738
clean:: ForeignTypeItem => sidebar_foreign_type ( cx, buffer, it) ,
1738
- _ => ( ) ,
1739
+ _ => { }
1739
1740
}
1740
1741
1741
1742
// The sidebar is designed to display sibling functions, modules and
@@ -1746,22 +1747,24 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
1746
1747
// as much HTML as possible in order to allow non-JS-enabled browsers
1747
1748
// to navigate the documentation (though slightly inefficiently).
1748
1749
1749
- buffer. write_str ( "<p class=\" location\" >" ) ;
1750
- for ( i, name) in cx. current . iter ( ) . take ( parentlen) . enumerate ( ) {
1751
- if i > 0 {
1752
- buffer. write_str ( "::<wbr>" ) ;
1750
+ if !it. is_mod ( ) {
1751
+ buffer. write_str ( "<p class=\" location\" >Other items in<br>" ) ;
1752
+ for ( i, name) in cx. current . iter ( ) . take ( parentlen) . enumerate ( ) {
1753
+ if i > 0 {
1754
+ buffer. write_str ( "::<wbr>" ) ;
1755
+ }
1756
+ write ! (
1757
+ buffer,
1758
+ "<a href=\" {}index.html\" >{}</a>" ,
1759
+ & cx. root_path( ) [ ..( cx. current. len( ) - i - 1 ) * 3 ] ,
1760
+ * name
1761
+ ) ;
1753
1762
}
1754
- write ! (
1755
- buffer,
1756
- "<a href=\" {}index.html\" >{}</a>" ,
1757
- & cx. root_path( ) [ ..( cx. current. len( ) - i - 1 ) * 3 ] ,
1758
- * name
1759
- ) ;
1763
+ buffer. write_str ( "</p>" ) ;
1760
1764
}
1761
- buffer. write_str ( "</p>" ) ;
1762
1765
1763
1766
// Sidebar refers to the enclosing module, not this module.
1764
- let relpath = if it. is_mod ( ) { ". ./" } else { "" } ;
1767
+ let relpath = if it. is_mod ( ) && parentlen != 0 { "./" } else { "" } ;
1765
1768
write ! (
1766
1769
buffer,
1767
1770
"<div id=\" sidebar-vars\" data-name=\" {name}\" data-ty=\" {ty}\" data-relpath=\" {path}\" >\
@@ -1770,17 +1773,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
1770
1773
ty = it. type_( ) ,
1771
1774
path = relpath
1772
1775
) ;
1773
-
1774
- if parentlen == 0 {
1775
- write ! (
1776
- buffer,
1777
- "<script defer src=\" {}sidebar-items{}.js\" ></script>" ,
1778
- relpath, cx. shared. resource_suffix
1779
- ) ;
1780
- } else {
1781
- write ! ( buffer, "<script defer src=\" {}sidebar-items.js\" ></script>" , relpath) ;
1782
- }
1783
-
1776
+ write ! ( buffer, "<script defer src=\" {}sidebar-items.js\" ></script>" , relpath) ;
1784
1777
// Closes sidebar-elems div.
1785
1778
buffer. write_str ( "</div>" ) ;
1786
1779
}
@@ -2288,8 +2281,8 @@ fn sidebar_enum(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, e: &clean:
2288
2281
}
2289
2282
}
2290
2283
2291
- fn item_ty_to_strs ( ty : & ItemType ) -> ( & ' static str , & ' static str ) {
2292
- match * ty {
2284
+ fn item_ty_to_strs ( ty : ItemType ) -> ( & ' static str , & ' static str ) {
2285
+ match ty {
2293
2286
ItemType :: ExternCrate | ItemType :: Import => ( "reexports" , "Re-exports" ) ,
2294
2287
ItemType :: Module => ( "modules" , "Modules" ) ,
2295
2288
ItemType :: Struct => ( "structs" , "Structs" ) ,
@@ -2321,10 +2314,14 @@ fn item_ty_to_strs(ty: &ItemType) -> (&'static str, &'static str) {
2321
2314
fn sidebar_module ( buf : & mut Buffer , items : & [ clean:: Item ] ) {
2322
2315
let mut sidebar = String :: new ( ) ;
2323
2316
2317
+ // Re-exports are handled a bit differently because they can be extern crates or imports.
2324
2318
if items. iter ( ) . any ( |it| {
2325
- it. type_ ( ) == ItemType :: ExternCrate || ( it. type_ ( ) == ItemType :: Import && !it. is_stripped ( ) )
2319
+ it. name . is_some ( )
2320
+ && ( it. type_ ( ) == ItemType :: ExternCrate
2321
+ || ( it. type_ ( ) == ItemType :: Import && !it. is_stripped ( ) ) )
2326
2322
} ) {
2327
- sidebar. push_str ( "<li><a href=\" #reexports\" >Re-exports</a></li>" ) ;
2323
+ let ( id, name) = item_ty_to_strs ( ItemType :: Import ) ;
2324
+ sidebar. push_str ( & format ! ( "<li><a href=\" #{}\" >{}</a></li>" , id, name) ) ;
2328
2325
}
2329
2326
2330
2327
// ordering taken from item_module, reorder, where it prioritized elements in a certain order
@@ -2351,13 +2348,9 @@ fn sidebar_module(buf: &mut Buffer, items: &[clean::Item]) {
2351
2348
ItemType :: ForeignType ,
2352
2349
ItemType :: Keyword ,
2353
2350
] {
2354
- if items. iter ( ) . any ( |it| !it. is_stripped ( ) && it. type_ ( ) == myty) {
2355
- let ( short, name) = item_ty_to_strs ( & myty) ;
2356
- sidebar. push_str ( & format ! (
2357
- "<li><a href=\" #{id}\" >{name}</a></li>" ,
2358
- id = short,
2359
- name = name
2360
- ) ) ;
2351
+ if items. iter ( ) . any ( |it| !it. is_stripped ( ) && it. type_ ( ) == myty && it. name . is_some ( ) ) {
2352
+ let ( id, name) = item_ty_to_strs ( myty) ;
2353
+ sidebar. push_str ( & format ! ( "<li><a href=\" #{}\" >{}</a></li>" , id, name) ) ;
2361
2354
}
2362
2355
}
2363
2356
0 commit comments