File tree 5 files changed +44
-1
lines changed
5 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -1124,6 +1124,7 @@ crate fn plain_text_summary(md: &str) -> String {
1124
1124
Event :: HardBreak | Event :: SoftBreak => s. push ( ' ' ) ,
1125
1125
Event :: Start ( Tag :: CodeBlock ( ..) ) => break ,
1126
1126
Event :: End ( Tag :: Paragraph ) => break ,
1127
+ Event :: End ( Tag :: Heading ( ..) ) => break ,
1127
1128
_ => ( ) ,
1128
1129
}
1129
1130
}
Original file line number Diff line number Diff line change @@ -230,6 +230,7 @@ fn test_plain_text_summary() {
230
230
t ( "code `let x = i32;` ..." , "code `let x = i32;` ..." ) ;
231
231
t ( "type `Type<'static>` ..." , "type `Type<'static>` ..." ) ;
232
232
t ( "# top header" , "top header" ) ;
233
+ t ( "# top header\n \n followed by some text" , "top header" ) ;
233
234
t ( "## header" , "header" ) ;
234
235
t ( "first paragraph\n \n second paragraph" , "first paragraph" ) ;
235
236
t ( "```\n fn main() {}\n ```" , "" ) ;
Original file line number Diff line number Diff line change @@ -1548,7 +1548,10 @@ impl Context<'_> {
1548
1548
}
1549
1549
title. push_str ( " - Rust" ) ;
1550
1550
let tyname = it. type_ ( ) ;
1551
- let desc = if it. is_crate ( ) {
1551
+ let desc = it. doc_value ( ) . as_ref ( ) . map ( |doc| plain_text_summary ( & doc) ) ;
1552
+ let desc = if let Some ( desc) = desc {
1553
+ desc
1554
+ } else if it. is_crate ( ) {
1552
1555
format ! ( "API documentation for the Rust `{}` crate." , self . shared. layout. krate)
1553
1556
} else {
1554
1557
format ! (
Original file line number Diff line number Diff line change
1
+ #![ crate_name = "foo" ]
2
+ //! # Description test crate
3
+ //!
4
+ //! This is the contents of the test crate docstring.
5
+ //! It should not show up in the description.
6
+
7
+ // @has 'foo/index.html' '//meta[@name="description"]/@content' \
8
+ // 'Description test crate'
9
+ // @!has - '//meta[@name="description"]/@content' 'should not show up'
10
+
11
+ // @has 'foo/foo_mod/index.html' '//meta[@name="description"]/@content' \
12
+ // 'First paragraph description.'
13
+ // @!has - '//meta[@name="description"]/@content' 'Second paragraph'
14
+ /// First paragraph description.
15
+ ///
16
+ /// Second paragraph should not show up.
17
+ pub mod foo_mod {
18
+ pub struct __Thing { }
19
+ }
20
+
21
+ // @has 'foo/fn.foo_fn.html' '//meta[@name="description"]/@content' \
22
+ // 'Only paragraph.'
23
+ /// Only paragraph.
24
+ pub fn foo_fn ( ) { }
Original file line number Diff line number Diff line change
1
+ #![ crate_name = "foo" ]
2
+
3
+ // @has 'foo/index.html' '//meta[@name="description"]/@content' \
4
+ // 'API documentation for the Rust `foo` crate.'
5
+
6
+ // @has 'foo/foo_mod/index.html' '//meta[@name="description"]/@content' \
7
+ // 'API documentation for the Rust `foo_mod` mod in crate `foo`.'
8
+ pub mod foo_mod {
9
+ pub struct __Thing { }
10
+ }
11
+
12
+ // @has 'foo/fn.foo_fn.html' '//meta[@name="description"]/@content' \
13
+ // 'API documentation for the Rust `foo_fn` fn in crate `foo`.'
14
+ pub fn foo_fn ( ) { }
You can’t perform that action at this time.
0 commit comments