@@ -2349,7 +2349,7 @@ impl Context {
2349
2349
} ;
2350
2350
let short = short. to_string ( ) ;
2351
2351
map. entry ( short) . or_default ( )
2352
- . push ( ( myname, Some ( plain_summary_line ( item. doc_value ( ) ) ) ) ) ;
2352
+ . push ( ( myname, Some ( plain_summary_line ( item. doc_value ( ) ) . 0 ) ) ) ;
2353
2353
}
2354
2354
2355
2355
if self . shared . sort_modules_alphabetically {
@@ -2563,9 +2563,24 @@ fn shorter(s: Option<&str>) -> String {
2563
2563
}
2564
2564
2565
2565
#[ inline]
2566
- fn plain_summary_line ( s : Option < & str > ) -> String {
2566
+ fn get_links < ' a , T : Iterator < Item = & ' a str > > ( it : T ) -> Vec < ( String , String ) > {
2567
+ it. filter ( |line| line. starts_with ( '[' ) && line. split ( "]: " ) . count ( ) == 2 )
2568
+ . map ( |line| {
2569
+ let parts = line. split ( "]: " ) . collect :: < Vec < _ > > ( ) ;
2570
+ ( ( & parts[ 0 ] [ 1 ..] ) . to_owned ( ) , parts[ 1 ] . trim ( ) . to_owned ( ) )
2571
+ } )
2572
+ . collect :: < Vec < _ > > ( )
2573
+ }
2574
+
2575
+ #[ inline]
2576
+ fn plain_summary_line ( s : Option < & str > ) -> ( String , Vec < ( String , String ) > ) {
2567
2577
let line = shorter ( s) . replace ( "\n " , " " ) ;
2568
- markdown:: plain_summary_line_full ( & line[ ..] , false )
2578
+ let links = if let Some ( ref s) = s {
2579
+ get_links ( s. split ( '\n' ) . skip ( 1 ) )
2580
+ } else {
2581
+ Vec :: new ( )
2582
+ } ;
2583
+ ( markdown:: plain_summary_line_full ( & line[ ..] , false ) , links)
2569
2584
}
2570
2585
2571
2586
#[ inline]
@@ -2607,13 +2622,16 @@ fn document_short(
2607
2622
prefix : & str , is_hidden : bool
2608
2623
) -> fmt:: Result {
2609
2624
if let Some ( s) = item. doc_value ( ) {
2610
- let markdown = if s. contains ( '\n' ) {
2611
- format ! ( "{} [Read more]({})" ,
2612
- & plain_summary_line ( Some ( s ) ) , naive_assoc_href( item, link) )
2625
+ let ( markdown, mut links ) = if s. contains ( '\n' ) {
2626
+ let ( text , links ) = plain_summary_line ( Some ( s ) ) ;
2627
+ ( format ! ( "{} [Read more]({})" , & text , naive_assoc_href( item, link) ) , links )
2613
2628
} else {
2614
2629
plain_summary_line ( Some ( s) )
2615
2630
} ;
2616
- render_markdown ( w, cx, & markdown, item. links ( ) , prefix, is_hidden) ?;
2631
+ for link in item. links ( ) {
2632
+ links. push ( link. clone ( ) ) ;
2633
+ }
2634
+ render_markdown ( w, cx, & markdown, links, prefix, is_hidden) ?;
2617
2635
} else if !prefix. is_empty ( ) {
2618
2636
write ! ( w, "<div class='docblock{}'>{}</div>" ,
2619
2637
if is_hidden { " hidden" } else { "" } ,
0 commit comments