From 6c67a7079f58c0e05021e8a1f4c5b7202995c66b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 10 Aug 2019 22:54:23 +0200 Subject: [PATCH 1/3] Generate urls for default trait items as well --- src/librustdoc/html/render.rs | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index b64e74468e6e9..08ceaa56846ae 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2349,7 +2349,7 @@ impl Context { }; let short = short.to_string(); map.entry(short).or_default() - .push((myname, Some(plain_summary_line(item.doc_value())))); + .push((myname, Some(plain_summary_line(item.doc_value()).0))); } if self.shared.sort_modules_alphabetically { @@ -2563,9 +2563,24 @@ fn shorter(s: Option<&str>) -> String { } #[inline] -fn plain_summary_line(s: Option<&str>) -> String { +fn get_links<'a, T: Iterator>(it: T) -> Vec<(String, String)> { + it.filter(|line| line.starts_with('[') && line.split("]: ").count() == 2) + .map(|line| { + let parts = line.split("]: ").collect::>(); + ((&parts[0][1..]).to_owned(), parts[1].trim().to_owned()) + }) + .collect::>() +} + +#[inline] +fn plain_summary_line(s: Option<&str>) -> (String, Vec<(String, String)>) { let line = shorter(s).replace("\n", " "); - markdown::plain_summary_line_full(&line[..], false) + let links = if let Some(ref s) = s { + get_links(s.split('\n').skip(1)) + } else { + Vec::new() + }; + (markdown::plain_summary_line_full(&line[..], false), links) } #[inline] @@ -2607,13 +2622,16 @@ fn document_short( prefix: &str, is_hidden: bool ) -> fmt::Result { if let Some(s) = item.doc_value() { - let markdown = if s.contains('\n') { - format!("{} [Read more]({})", - &plain_summary_line(Some(s)), naive_assoc_href(item, link)) + let (markdown, mut links) = if s.contains('\n') { + let (text, links) = plain_summary_line(Some(s)); + (format!("{} [Read more]({})", &text, naive_assoc_href(item, link)), links) } else { plain_summary_line(Some(s)) }; - render_markdown(w, cx, &markdown, item.links(), prefix, is_hidden)?; + for link in item.links() { + links.push(link.clone()); + } + render_markdown(w, cx, &markdown, links, prefix, is_hidden)?; } else if !prefix.is_empty() { write!(w, "
{}
", if is_hidden { " hidden" } else { "" }, From 26e14b8da6c0fa11f5bad9cd5b6191b554ed2c88 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 24 Aug 2019 23:45:47 +0200 Subject: [PATCH 2/3] Fix build failure in case file doesn't exist --- src/bootstrap/doc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 6805474aa049f..b103f985c70a1 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -375,7 +375,7 @@ impl Step for Standalone { up_to_date(&footer, &html) && up_to_date(&favicon, &html) && up_to_date(&full_toc, &html) && - up_to_date(&version_info, &html) && + (version_info.exists() && up_to_date(&version_info, &html)) && (builder.config.dry_run || up_to_date(&rustdoc, &html)) { continue } From 0e69b3c285863efa8afabe5129aa14f9d9e4405d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 25 Aug 2019 01:00:42 +0200 Subject: [PATCH 3/3] fixing links --- src/libcore/hash/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index bf3daa32840d8..40603c55cd273 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -169,7 +169,7 @@ pub trait Hash { /// println!("Hash is {:x}!", hasher.finish()); /// ``` /// - /// [`Hasher`]: trait.Hasher.html + /// [`Hasher`]: hash::Hasher #[stable(feature = "rust1", since = "1.0.0")] fn hash(&self, state: &mut H); @@ -187,7 +187,7 @@ pub trait Hash { /// println!("Hash is {:x}!", hasher.finish()); /// ``` /// - /// [`Hasher`]: trait.Hasher.html + /// [`Hasher`]: hash::Hasher #[stable(feature = "hash_slice", since = "1.3.0")] fn hash_slice(data: &[Self], state: &mut H) where Self: Sized