Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate urls for default trait items as well #63451

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<H: Hasher>(&self, state: &mut H);

Expand All @@ -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<H: Hasher>(data: &[Self], state: &mut H)
where Self: Sized
Expand Down
32 changes: 25 additions & 7 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<Item = &'a str>>(it: T) -> Vec<(String, String)> {
it.filter(|line| line.starts_with('[') && line.split("]: ").count() == 2)
.map(|line| {
let parts = line.split("]: ").collect::<Vec<_>>();
((&parts[0][1..]).to_owned(), parts[1].trim().to_owned())
})
.collect::<Vec<_>>()
}

#[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]
Expand Down Expand Up @@ -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, "<div class='docblock{}'>{}</div>",
if is_hidden { " hidden" } else { "" },
Expand Down