@@ -1703,7 +1703,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
17031703 "<div class=\" block version\" >\
17041704 <p>Version {}</p>\
17051705 </div>",
1706- Escape ( version)
1706+ Escape ( version) ,
17071707 ) ;
17081708 }
17091709 }
@@ -1713,9 +1713,10 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
17131713 write ! (
17141714 buffer,
17151715 "<a id=\" all-types\" href=\" all.html\" ><p>See all {}'s items</p></a>" ,
1716- it. name. as_ref( ) . expect( "crates always have a name" )
1716+ it. name. as_ref( ) . expect( "crates always have a name" ) ,
17171717 ) ;
17181718 }
1719+
17191720 match * it. kind {
17201721 clean:: StructItem ( ref s) => sidebar_struct ( cx, buffer, it, s) ,
17211722 clean:: TraitItem ( ref t) => sidebar_trait ( cx, buffer, it, t) ,
@@ -1725,7 +1726,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
17251726 clean:: TypedefItem ( _, _) => sidebar_typedef ( cx, buffer, it) ,
17261727 clean:: ModuleItem ( ref m) => sidebar_module ( buffer, & m. items ) ,
17271728 clean:: ForeignTypeItem => sidebar_foreign_type ( cx, buffer, it) ,
1728- _ => ( ) ,
1729+ _ => { }
17291730 }
17301731
17311732 // The sidebar is designed to display sibling functions, modules and
@@ -1736,22 +1737,24 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
17361737 // as much HTML as possible in order to allow non-JS-enabled browsers
17371738 // to navigate the documentation (though slightly inefficiently).
17381739
1739- buffer. write_str ( "<p class=\" location\" >" ) ;
1740- for ( i, name) in cx. current . iter ( ) . take ( parentlen) . enumerate ( ) {
1741- if i > 0 {
1742- buffer. write_str ( "::<wbr>" ) ;
1740+ if !it. is_mod ( ) {
1741+ buffer. write_str ( "<p class=\" location\" >" ) ;
1742+ for ( i, name) in cx. current . iter ( ) . take ( parentlen) . enumerate ( ) {
1743+ if i > 0 {
1744+ buffer. write_str ( "::<wbr>" ) ;
1745+ }
1746+ write ! (
1747+ buffer,
1748+ "<a href=\" {}index.html\" >{}</a>" ,
1749+ & cx. root_path( ) [ ..( cx. current. len( ) - i - 1 ) * 3 ] ,
1750+ * name
1751+ ) ;
17431752 }
1744- write ! (
1745- buffer,
1746- "<a href=\" {}index.html\" >{}</a>" ,
1747- & cx. root_path( ) [ ..( cx. current. len( ) - i - 1 ) * 3 ] ,
1748- * name
1749- ) ;
1753+ buffer. write_str ( "</p>" ) ;
17501754 }
1751- buffer. write_str ( "</p>" ) ;
17521755
17531756 // Sidebar refers to the enclosing module, not this module.
1754- let relpath = if it. is_mod ( ) { ". ./" } else { "" } ;
1757+ let relpath = if it. is_mod ( ) && parentlen != 0 { "./" } else { "" } ;
17551758 write ! (
17561759 buffer,
17571760 "<div id=\" sidebar-vars\" data-name=\" {name}\" data-ty=\" {ty}\" data-relpath=\" {path}\" >\
@@ -1760,17 +1763,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
17601763 ty = it. type_( ) ,
17611764 path = relpath
17621765 ) ;
1763-
1764- if parentlen == 0 {
1765- write ! (
1766- buffer,
1767- "<script defer src=\" {}sidebar-items{}.js\" ></script>" ,
1768- relpath, cx. shared. resource_suffix
1769- ) ;
1770- } else {
1771- write ! ( buffer, "<script defer src=\" {}sidebar-items.js\" ></script>" , relpath) ;
1772- }
1773-
1766+ write ! ( buffer, "<script defer src=\" {}sidebar-items.js\" ></script>" , relpath) ;
17741767 // Closes sidebar-elems div.
17751768 buffer. write_str ( "</div>" ) ;
17761769}
@@ -2278,8 +2271,8 @@ fn sidebar_enum(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, e: &clean:
22782271 }
22792272}
22802273
2281- fn item_ty_to_strs ( ty : & ItemType ) -> ( & ' static str , & ' static str ) {
2282- match * ty {
2274+ fn item_ty_to_strs ( ty : ItemType ) -> ( & ' static str , & ' static str ) {
2275+ match ty {
22832276 ItemType :: ExternCrate | ItemType :: Import => ( "reexports" , "Re-exports" ) ,
22842277 ItemType :: Module => ( "modules" , "Modules" ) ,
22852278 ItemType :: Struct => ( "structs" , "Structs" ) ,
@@ -2311,10 +2304,14 @@ fn item_ty_to_strs(ty: &ItemType) -> (&'static str, &'static str) {
23112304fn sidebar_module ( buf : & mut Buffer , items : & [ clean:: Item ] ) {
23122305 let mut sidebar = String :: new ( ) ;
23132306
2307+ // Re-exports are handled a bit differently because they can be extern crates or imports.
23142308 if items. iter ( ) . any ( |it| {
2315- it. type_ ( ) == ItemType :: ExternCrate || ( it. type_ ( ) == ItemType :: Import && !it. is_stripped ( ) )
2309+ it. name . is_some ( )
2310+ && ( it. type_ ( ) == ItemType :: ExternCrate
2311+ || ( it. type_ ( ) == ItemType :: Import && !it. is_stripped ( ) ) )
23162312 } ) {
2317- sidebar. push_str ( "<li><a href=\" #reexports\" >Re-exports</a></li>" ) ;
2313+ let ( id, name) = item_ty_to_strs ( ItemType :: Import ) ;
2314+ sidebar. push_str ( & format ! ( "<li><a href=\" #{}\" >{}</a></li>" , id, name) ) ;
23182315 }
23192316
23202317 // ordering taken from item_module, reorder, where it prioritized elements in a certain order
@@ -2341,13 +2338,9 @@ fn sidebar_module(buf: &mut Buffer, items: &[clean::Item]) {
23412338 ItemType :: ForeignType ,
23422339 ItemType :: Keyword ,
23432340 ] {
2344- if items. iter ( ) . any ( |it| !it. is_stripped ( ) && it. type_ ( ) == myty) {
2345- let ( short, name) = item_ty_to_strs ( & myty) ;
2346- sidebar. push_str ( & format ! (
2347- "<li><a href=\" #{id}\" >{name}</a></li>" ,
2348- id = short,
2349- name = name
2350- ) ) ;
2341+ if items. iter ( ) . any ( |it| !it. is_stripped ( ) && it. type_ ( ) == myty && it. name . is_some ( ) ) {
2342+ let ( id, name) = item_ty_to_strs ( myty) ;
2343+ sidebar. push_str ( & format ! ( "<li><a href=\" #{}\" >{}</a></li>" , id, name) ) ;
23512344 }
23522345 }
23532346
0 commit comments