Skip to content

Commit 6e44653

Browse files
committed
Auto merge of #31602 - mitaa:rdoc_doc_shorter, r=alexcrichton
fixes #25787 fixes #30366 r? @alexcrichton
2 parents c438802 + 5c98ae3 commit 6e44653

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/librustdoc/html/render.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1653,8 +1653,8 @@ fn shorter<'a>(s: Option<&'a str>) -> String {
16531653

16541654
#[inline]
16551655
fn plain_summary_line(s: Option<&str>) -> String {
1656-
let line = shorter(s).replace("\n", " ");
1657-
markdown::plain_summary_line(&line[..])
1656+
let md = markdown::plain_summary_line(s.unwrap_or(""));
1657+
shorter(Some(&md)).replace("\n", " ")
16581658
}
16591659

16601660
fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result {
@@ -1781,6 +1781,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
17811781
} else {
17821782
String::new()
17831783
};
1784+
let doc_value = myitem.doc_value().unwrap_or("");
17841785
try!(write!(w, "
17851786
<tr class='{stab} module-item'>
17861787
<td><a class='{class}' href='{href}'
@@ -1792,7 +1793,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
17921793
",
17931794
name = *myitem.name.as_ref().unwrap(),
17941795
stab_docs = stab_docs,
1795-
docs = Markdown(&shorter(myitem.doc_value())),
1796+
docs = shorter(Some(&Markdown(doc_value).to_string())),
17961797
class = shortty(myitem),
17971798
stab = myitem.stability_class(),
17981799
href = item_path(myitem),

src/test/rustdoc/issue-30366.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// @has issue_30366/index.html '//a/@href' 'http://www.rust-lang.org/'
12+
13+
/// Describe it. [Link somewhere][1].
14+
///
15+
/// [1]: http://www.rust-lang.org/
16+
pub fn here_is_a_fn() { }

0 commit comments

Comments
 (0)