@@ -102,13 +102,11 @@ pub enum ExternalLocation {
102
102
Unknown ,
103
103
}
104
104
105
- /// Different ways an implementor of a trait can be rendered.
106
- pub enum Implementor {
107
- /// Paths are displayed specially by omitting the `impl XX for` cruft
108
- PathType ( clean:: Type ) ,
109
- /// This is the generic representation of a trait implementor, used for
110
- /// primitive types and otherwise non-path types.
111
- OtherType ( clean:: Generics , /* trait */ clean:: Type , /* for */ clean:: Type ) ,
105
+ /// Metadata about an implementor of a trait.
106
+ pub struct Implementor {
107
+ generics : clean:: Generics ,
108
+ trait_ : clean:: Type ,
109
+ for_ : clean:: Type ,
112
110
}
113
111
114
112
/// This cache is used to store information about the `clean::Crate` being
@@ -312,6 +310,7 @@ pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> {
312
310
// for future parallelization opportunities
313
311
let cache = Arc :: new ( cache) ;
314
312
cache_key. replace ( Some ( cache. clone ( ) ) ) ;
313
+ current_location_key. replace ( Some ( Vec :: new ( ) ) ) ;
315
314
316
315
try!( write_shared ( & cx, & krate, & * cache, index) ) ;
317
316
let krate = try!( render_sources ( & mut cx, krate) ) ;
@@ -476,7 +475,6 @@ fn write_shared(cx: &Context,
476
475
let dst = cx. dst . join ( "implementors" ) ;
477
476
try!( mkdir ( & dst) ) ;
478
477
for ( & did, imps) in cache. implementors . iter ( ) {
479
- if ast_util:: is_local ( did) { continue }
480
478
let & ( ref remote_path, remote_item_type) = cache. paths . get ( & did) ;
481
479
482
480
let mut mydst = dst. clone ( ) ;
@@ -495,25 +493,15 @@ fn write_shared(cx: &Context,
495
493
try!( writeln ! ( & mut f, r"(function() \{var implementors = \{\};" ) ) ;
496
494
497
495
for implementor in all_implementors. iter ( ) {
498
- try!( writeln ! ( & mut f, "{}" , * implementor) ) ;
496
+ try!( write ! ( & mut f, "{}" , * implementor) ) ;
499
497
}
500
498
501
- try!( write ! ( & mut f, r"implementors['{}'] = \{ " , krate. name) ) ;
499
+ try!( write ! ( & mut f, r"implementors['{}'] = [ " , krate. name) ) ;
502
500
for imp in imps. iter ( ) {
503
- let & ( ref path, item_type) = match * imp {
504
- PathType ( clean:: ResolvedPath { did, .. } ) => {
505
- cache. paths . get ( & did)
506
- }
507
- PathType ( ..) | OtherType ( ..) => continue ,
508
- } ;
509
- try!( write ! ( & mut f, r#"{}:"# , * path. get( path. len( ) - 1 ) ) ) ;
510
- try!( write ! ( & mut f, r#""{}"# ,
511
- path. slice_to( path. len( ) - 1 ) . connect( "/" ) ) ) ;
512
- try!( write ! ( & mut f, r#"/{}.{}.html","# ,
513
- item_type. to_static_str( ) ,
514
- * path. get( path. len( ) - 1 ) ) ) ;
501
+ try!( write ! ( & mut f, r#""impl{} {} for {}","# ,
502
+ imp. generics, imp. trait_, imp. for_) ) ;
515
503
}
516
- try!( writeln ! ( & mut f, r"\} ;" ) ) ;
504
+ try!( writeln ! ( & mut f, r"] ;" ) ) ;
517
505
try!( writeln ! ( & mut f, "{}" , r"
518
506
if (window.register_implementors) {
519
507
window.register_implementors(implementors);
@@ -737,16 +725,11 @@ impl DocFolder for Cache {
737
725
let v = self . implementors . find_or_insert_with ( did, |_| {
738
726
Vec :: new ( )
739
727
} ) ;
740
- match i. for_ {
741
- clean:: ResolvedPath { ..} => {
742
- v. unshift ( PathType ( i. for_ . clone ( ) ) ) ;
743
- }
744
- _ => {
745
- v. push ( OtherType ( i. generics . clone ( ) ,
746
- i. trait_ . get_ref ( ) . clone ( ) ,
747
- i. for_ . clone ( ) ) ) ;
748
- }
749
- }
728
+ v. push ( Implementor {
729
+ generics : i. generics . clone ( ) ,
730
+ trait_ : i. trait_ . get_ref ( ) . clone ( ) ,
731
+ for_ : i. for_ . clone ( ) ,
732
+ } ) ;
750
733
}
751
734
Some ( ..) | None => { }
752
735
}
@@ -1489,34 +1472,33 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
1489
1472
try!( write ! ( w, "</div>" ) ) ;
1490
1473
}
1491
1474
1492
- match cache_key. get ( ) . unwrap ( ) . implementors . find ( & it. def_id ) {
1475
+ let cache = cache_key. get ( ) . unwrap ( ) ;
1476
+ try!( write ! ( w, "
1477
+ <h2 id='implementors'>Implementors</h2>
1478
+ <ul class='item-list' id='implementors-list'>
1479
+ " ) ) ;
1480
+ match cache. implementors . find ( & it. def_id ) {
1493
1481
Some ( implementors) => {
1494
- try!( write ! ( w, "
1495
- <h2 id='implementors'>Implementors</h2>
1496
- <ul class='item-list' id='implementors-list'>
1497
- " ) ) ;
1498
1482
for i in implementors. iter ( ) {
1499
- match * i {
1500
- PathType ( ref ty) => {
1501
- try!( write ! ( w, "<li><code>{}</code></li>" , * ty) ) ;
1502
- }
1503
- OtherType ( ref generics, ref trait_, ref for_) => {
1504
- try!( write ! ( w, "<li><code>impl{} {} for {}</code></li>" ,
1505
- * generics, * trait_, * for_) ) ;
1506
- }
1507
- }
1483
+ try!( writeln ! ( w, "<li><code>impl{} {} for {}</code></li>" ,
1484
+ i. generics, i. trait_, i. for_) ) ;
1508
1485
}
1509
- try!( write ! ( w, "</ul>" ) ) ;
1510
- try!( write ! ( w, r#"<script type="text/javascript" async
1511
- src="{}/implementors/{}/{}.{}.js"></script>"# ,
1512
- cx. current. iter( ) . map( |_| ".." )
1513
- . collect:: <Vec <& str >>( ) . connect( "/" ) ,
1514
- cx. current. connect( "/" ) ,
1515
- shortty( it) . to_static_str( ) ,
1516
- * it. name. get_ref( ) ) ) ;
1517
1486
}
1518
1487
None => { }
1519
1488
}
1489
+ try!( write ! ( w, "</ul>" ) ) ;
1490
+ try!( write ! ( w, r#"<script type="text/javascript" async
1491
+ src="{root_path}/implementors/{path}/\
1492
+ {ty}.{name}.js"></script>"# ,
1493
+ root_path = Vec :: from_elem( cx. current. len( ) , ".." ) . connect( "/" ) ,
1494
+ path = if ast_util:: is_local( it. def_id) {
1495
+ cx. current. connect( "/" )
1496
+ } else {
1497
+ let path = cache. external_paths. get( & it. def_id) ;
1498
+ path. slice_to( path. len( ) - 1 ) . connect( "/" )
1499
+ } ,
1500
+ ty = shortty( it) . to_static_str( ) ,
1501
+ name = * it. name. get_ref( ) ) ) ;
1520
1502
Ok ( ( ) )
1521
1503
}
1522
1504
0 commit comments