From 962c0a4ee59e3c1a2413e785694c9433ffd0a9e1 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Fri, 3 Dec 2021 17:09:04 -0800 Subject: Make source links look cleaner Change from syntaxy-looking [src] to the plain word "source". --- src/librustdoc/html/render/context.rs | 2 +- src/librustdoc/html/render/mod.rs | 14 +++++++++----- src/librustdoc/html/render/print_item.rs | 6 +++--- 3 files changed, 13 insertions(+), 9 deletions(-) (limited to 'src/librustdoc/html/render') diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 534a542d58e..2ae203e0d2f 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -65,7 +65,7 @@ crate struct Context<'tcx> { /// /// [#82381]: https://github.com/rust-lang/rust/issues/82381 crate shared: Rc>, - /// This flag indicates whether `[src]` links should be generated or not. If + /// This flag indicates whether source links should be generated or not. If /// the source files are present in the html rendering, then this will be /// `true`. crate include_sources: bool, diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 16334890da6..1af847b81d5 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -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, "[src]", l) + write!(buf, "source", l) } } @@ -807,7 +807,7 @@ fn render_stability_since_raw( const_stability: Option, containing_ver: Option, containing_const_ver: Option, -) { +) -> bool { let ver = ver.filter(|inner| !inner.is_empty()); match (ver, const_stability) { @@ -850,8 +850,9 @@ fn render_stability_since_raw( v ); } - _ => {} + _ => return false, } + true } fn render_assoc_item( @@ -1640,7 +1641,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<'_>, @@ -1658,13 +1659,16 @@ fn render_rightside( }; write!(w, "
"); - 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("
"); diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 44a9ec5ea42..9f2830ba542 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -108,10 +108,10 @@ pub(super) fn print_item( ); let stability_since_raw: String = stability_since_raw.into_inner(); - // Write `src` tag + // Write source tag // // When this item is part of a `crate use` in a downstream crate, the - // [src] link in the downstream documentation will actually come back to + // source link in the downstream documentation will actually come back to // this page, and this link will be auto-clicked. The `id` attribute is // used to find the link to auto-click. let src_href = @@ -1467,7 +1467,7 @@ fn render_stability_since( item.const_stability(tcx), containing_item.stable_since(tcx), containing_item.const_stable_since(tcx), - ) + ); } fn compare_impl<'a, 'b>(lhs: &'a &&Impl, rhs: &'b &&Impl, cx: &Context<'_>) -> Ordering { -- cgit 1.4.1-3-g733a5