@@ -26,12 +26,13 @@ use crate::formats::item_type::ItemType;
26
26
use crate :: formats:: { AssocItemRender , Impl , RenderMode } ;
27
27
use crate :: html:: escape:: Escape ;
28
28
use crate :: html:: format:: {
29
- join_with_double_colon, join_with_slash , print_abi_with_space, print_constness_with_space,
30
- print_where_clause , Buffer , PrintWithSpace ,
29
+ join_with_double_colon, print_abi_with_space, print_constness_with_space, print_where_clause ,
30
+ Buffer , PrintWithSpace ,
31
31
} ;
32
32
use crate :: html:: highlight;
33
33
use crate :: html:: layout:: Page ;
34
34
use crate :: html:: markdown:: { HeadingOffset , MarkdownSummaryLine } ;
35
+ use crate :: html:: url_parts_builder:: UrlPartsBuilder ;
35
36
36
37
use askama:: Template ;
37
38
@@ -854,20 +855,21 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
854
855
}
855
856
}
856
857
858
+ let mut js_src_path: UrlPartsBuilder = std:: iter:: repeat ( ".." )
859
+ . take ( cx. current . len ( ) )
860
+ . chain ( std:: iter:: once ( "implementors" ) )
861
+ . collect ( ) ;
862
+ if it. def_id . is_local ( ) {
863
+ js_src_path. extend ( cx. current . iter ( ) . copied ( ) ) ;
864
+ } else {
865
+ let ( ref path, _) = cache. external_paths [ & it. def_id . expect_def_id ( ) ] ;
866
+ js_src_path. extend ( path[ ..path. len ( ) - 1 ] . iter ( ) . copied ( ) ) ;
867
+ }
868
+ js_src_path. push_fmt ( format_args ! ( "{}.{}.js" , it. type_( ) , it. name. unwrap( ) ) ) ;
857
869
write ! (
858
870
w,
859
- "<script type=\" text/javascript\" \
860
- src=\" {root_path}/implementors/{path}/{ty}.{name}.js\" async>\
861
- </script>",
862
- root_path = vec![ ".." ; cx. current. len( ) ] . join( "/" ) ,
863
- path = if it. def_id. is_local( ) {
864
- join_with_slash( None , & cx. current)
865
- } else {
866
- let ( ref path, _) = cache. external_paths[ & it. def_id. expect_def_id( ) ] ;
867
- join_with_slash( None , & path[ ..path. len( ) - 1 ] )
868
- } ,
869
- ty = it. type_( ) ,
870
- name = it. name. unwrap( )
871
+ "<script type=\" text/javascript\" src=\" {src}\" async></script>" ,
872
+ src = js_src_path. finish( ) ,
871
873
) ;
872
874
}
873
875
0 commit comments