File tree Expand file tree Collapse file tree 5 files changed +44
-1
lines changed Expand file tree Collapse file tree 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 {
11241124 Event :: HardBreak | Event :: SoftBreak => s. push ( ' ' ) ,
11251125 Event :: Start ( Tag :: CodeBlock ( ..) ) => break ,
11261126 Event :: End ( Tag :: Paragraph ) => break ,
1127+ Event :: End ( Tag :: Heading ( ..) ) => break ,
11271128 _ => ( ) ,
11281129 }
11291130 }
Original file line number Diff line number Diff line change @@ -230,6 +230,7 @@ fn test_plain_text_summary() {
230230 t ( "code `let x = i32;` ..." , "code `let x = i32;` ..." ) ;
231231 t ( "type `Type<'static>` ..." , "type `Type<'static>` ..." ) ;
232232 t ( "# top header" , "top header" ) ;
233+ t ( "# top header\n \n followed by some text" , "top header" ) ;
233234 t ( "## header" , "header" ) ;
234235 t ( "first paragraph\n \n second paragraph" , "first paragraph" ) ;
235236 t ( "```\n fn main() {}\n ```" , "" ) ;
Original file line number Diff line number Diff line change @@ -1548,7 +1548,10 @@ impl Context<'_> {
15481548 }
15491549 title. push_str ( " - Rust" ) ;
15501550 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 ( ) {
15521555 format ! ( "API documentation for the Rust `{}` crate." , self . shared. layout. krate)
15531556 } else {
15541557 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