@@ -1713,7 +1713,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
17131713 "<div class=\" block version\" >\
17141714 <p>Version {}</p>\
17151715 </div>",
1716- Escape ( version)
1716+ Escape ( version) ,
17171717 ) ;
17181718 }
17191719 }
@@ -1723,9 +1723,10 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
17231723 write ! (
17241724 buffer,
17251725 "<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" ) ,
17271727 ) ;
17281728 }
1729+
17291730 match * it. kind {
17301731 clean:: StructItem ( ref s) => sidebar_struct ( cx, buffer, it, s) ,
17311732 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) {
17351736 clean:: TypedefItem ( _, _) => sidebar_typedef ( cx, buffer, it) ,
17361737 clean:: ModuleItem ( ref m) => sidebar_module ( buffer, & m. items ) ,
17371738 clean:: ForeignTypeItem => sidebar_foreign_type ( cx, buffer, it) ,
1738- _ => ( ) ,
1739+ _ => { }
17391740 }
17401741
17411742 // 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) {
17461747 // as much HTML as possible in order to allow non-JS-enabled browsers
17471748 // to navigate the documentation (though slightly inefficiently).
17481749
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+ ) ;
17531762 }
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>" ) ;
17601764 }
1761- buffer. write_str ( "</p>" ) ;
17621765
17631766 // 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 { "" } ;
17651768 write ! (
17661769 buffer,
17671770 "<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) {
17701773 ty = it. type_( ) ,
17711774 path = relpath
17721775 ) ;
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) ;
17841777 // Closes sidebar-elems div.
17851778 buffer. write_str ( "</div>" ) ;
17861779}
@@ -2288,8 +2281,8 @@ fn sidebar_enum(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, e: &clean:
22882281 }
22892282}
22902283
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 {
22932286 ItemType :: ExternCrate | ItemType :: Import => ( "reexports" , "Re-exports" ) ,
22942287 ItemType :: Module => ( "modules" , "Modules" ) ,
22952288 ItemType :: Struct => ( "structs" , "Structs" ) ,
@@ -2321,10 +2314,14 @@ fn item_ty_to_strs(ty: &ItemType) -> (&'static str, &'static str) {
23212314fn sidebar_module ( buf : & mut Buffer , items : & [ clean:: Item ] ) {
23222315 let mut sidebar = String :: new ( ) ;
23232316
2317+ // Re-exports are handled a bit differently because they can be extern crates or imports.
23242318 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 ( ) ) )
23262322 } ) {
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) ) ;
23282325 }
23292326
23302327 // 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]) {
23512348 ItemType :: ForeignType ,
23522349 ItemType :: Keyword ,
23532350 ] {
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) ) ;
23612354 }
23622355 }
23632356
0 commit comments