1
Fork 0

Rollup merge of #92602 - jsha:source-link-2, r=GuillaumeGomez

Make source links look cleaner

Change from syntaxy-looking [src] to the plain word "source".

Change the syntaxy-looking `[-]` at the top of the page to say "collapse".

Reduce opacity of rightside content.

Part of #59851

r? `@GuillaumeGomez`

Demo: https://rustdoc.crud.net/jsha/source-link-2/std/string/struct.String.html

[Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/display.20of.20source.20link).
This commit is contained in:
Matthias Krüger 2022-01-10 11:03:06 +01:00 committed by GitHub
commit a4ac4fae41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 96 additions and 79 deletions

View file

@ -182,7 +182,7 @@ impl StylePath {
fn write_srclink(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer) {
if let Some(l) = cx.src_href(item) {
write!(buf, "<a class=\"srclink\" href=\"{}\" title=\"goto source code\">[src]</a>", l)
write!(buf, "<a class=\"srclink\" href=\"{}\" title=\"goto source code\">source</a>", l)
}
}
@ -799,7 +799,7 @@ fn render_stability_since_raw(
const_stability: Option<ConstStability>,
containing_ver: Option<Symbol>,
containing_const_ver: Option<Symbol>,
) {
) -> bool {
let ver = ver.filter(|inner| !inner.is_empty());
match (ver, const_stability) {
@ -842,8 +842,9 @@ fn render_stability_since_raw(
v
);
}
_ => {}
_ => return false,
}
true
}
fn render_assoc_item(
@ -1632,7 +1633,7 @@ fn render_impl(
}
// Render the items that appear on the right side of methods, impls, and
// associated types. For example "1.0.0 (const: 1.39.0) [src]".
// associated types. For example "1.0.0 (const: 1.39.0) · source".
fn render_rightside(
w: &mut Buffer,
cx: &Context<'_>,
@ -1650,13 +1651,16 @@ fn render_rightside(
};
write!(w, "<div class=\"rightside\">");
render_stability_since_raw(
let has_stability = render_stability_since_raw(
w,
item.stable_since(tcx),
const_stability,
containing_item.stable_since(tcx),
const_stable_since,
);
if has_stability {
w.write_str(" · ");
}
write_srclink(cx, item, w);
w.write_str("</div>");