diff options
| author | Jacob Hoffman-Andrews <github@hoffman-andrews.com> | 2021-06-08 11:04:53 -0700 |
|---|---|---|
| committer | Jacob Hoffman-Andrews <github@hoffman-andrews.com> | 2021-06-16 22:20:25 -0700 |
| commit | 593d6d1cb15c55c88319470dabb40126c7b7f1e2 (patch) | |
| tree | 880f941112df0f2a46e1cad4fac5e8b45d0d3365 | |
| parent | 910c7fa7673b80ead337c5d37259c9ff4dcf355c (diff) | |
| download | rust-593d6d1cb15c55c88319470dabb40126c7b7f1e2.tar.gz rust-593d6d1cb15c55c88319470dabb40126c7b7f1e2.zip | |
Make portability part of the summary.
That means it will be visible under "Implementors" on trait pages, and under "Implementations" on struct/enum pages, even when all methods are collapsed. Switch to a float layout for rightside elements.
| -rw-r--r-- | src/librustdoc/html/render/mod.rs | 17 | ||||
| -rw-r--r-- | src/librustdoc/html/render/print_item.rs | 13 | ||||
| -rw-r--r-- | src/librustdoc/html/static/rustdoc.css | 12 | ||||
| -rw-r--r-- | src/test/rustdoc/src-links-auto-impls.rs | 6 |
4 files changed, 27 insertions, 21 deletions
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 4ce14e6eb3c..df8cc94d3ee 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1552,6 +1552,7 @@ fn render_impl( w, cx, i, + parent, outer_version, outer_const_version, show_def_docs, @@ -1562,11 +1563,6 @@ fn render_impl( if toggled { write!(w, "</summary>") } - if trait_.is_some() { - if let Some(portability) = portability(&i.impl_item, Some(parent)) { - write!(w, "<div class=\"item-info\">{}</div>", portability); - } - } if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) { let mut ids = cx.id_map.borrow_mut(); @@ -1598,6 +1594,7 @@ pub(crate) fn render_impl_summary( w: &mut Buffer, cx: &Context<'_>, i: &Impl, + parent: &clean::Item, outer_version: Option<&str>, outer_const_version: Option<&str>, show_def_docs: bool, @@ -1652,6 +1649,7 @@ pub(crate) fn render_impl_summary( ); } write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id); + write!(w, "<div class=\"rightside\">"); render_stability_since_raw( w, i.impl_item.stable_since(tcx).as_deref(), @@ -1660,6 +1658,15 @@ pub(crate) fn render_impl_summary( outer_const_version, ); write_srclink(cx, &i.impl_item, w); + w.write_str("</div>"); // end of "rightside" + + let is_trait = i.inner_impl().trait_.is_some(); + if is_trait { + if let Some(portability) = portability(&i.impl_item, Some(parent)) { + write!(w, "<div class=\"item-info\">{}</div>", portability); + } + } + w.write_str("</div>"); } diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 5be16d1ce50..8ad0a803441 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -585,11 +585,14 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra if toggled { write!(w, "<details class=\"rustdoc-toggle\" open><summary>"); } - write!(w, "<div id=\"{}\" class=\"method has-srclink\"><code>", id); - render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl, cx); - w.write_str("</code>"); + write!(w, "<div id=\"{}\" class=\"method has-srclink\">", id); + write!(w, "<div class=\"rightside\">"); render_stability_since(w, m, t, cx.tcx()); write_srclink(cx, m, w); + write!(w, "</div>"); + write!(w, "<code>"); + render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl, cx); + w.write_str("</code>"); w.write_str("</div>"); if toggled { write!(w, "</summary>"); @@ -697,6 +700,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra w, cx, &implementor, + it, outer_version.as_deref(), outer_const_version.as_deref(), false, @@ -1305,7 +1309,7 @@ fn render_implementor( implementor_dups: &FxHashMap<Symbol, (DefId, bool)>, aliases: &[String], ) { - // If there's already another implementor that has the same abbridged name, use the + // If there's already another implementor that has the same abridged name, use the // full path, for example in `std::iter::ExactSizeIterator` let use_absolute = match implementor.inner_impl().for_ { clean::ResolvedPath { ref path, is_generic: false, .. } @@ -1321,6 +1325,7 @@ fn render_implementor( w, cx, implementor, + trait_, outer_version.as_deref(), outer_const_version.as_deref(), false, diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 7535145caa5..e084ee9ca7e 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -581,7 +581,6 @@ nav.sub { .content .item-info { position: relative; margin-left: 33px; - margin-top: -13px; } .sub-variant > div > .item-info { @@ -852,12 +851,12 @@ body.blur > :not(#help) { } .stab { - display: table; border-width: 1px; border-style: solid; padding: 3px; margin-bottom: 5px; font-size: 90%; + font-weight: normal; } .stab p { display: inline; @@ -906,26 +905,22 @@ body.blur > :not(#help) { } .impl-items .since, .impl .since, .methods .since { - flex-grow: 0; padding-left: 12px; padding-right: 2px; position: initial; } .impl-items .srclink, .impl .srclink, .methods .srclink { - flex-grow: 0; /* Override header settings otherwise it's too bold */ font-size: 17px; font-weight: normal; } -.impl-items code, .impl code, .methods code { - flex-grow: 1; +.rightside { + float: right; } .has-srclink { - display: flex; - flex-basis: 100%; font-size: 16px; margin-bottom: 12px; /* Push the src link out to the right edge consistently */ @@ -986,7 +981,6 @@ a.test-arrow:hover{ } .since + .srclink { - display: table-cell; padding-left: 10px; } diff --git a/src/test/rustdoc/src-links-auto-impls.rs b/src/test/rustdoc/src-links-auto-impls.rs index 6f609e080d3..1952f723465 100644 --- a/src/test/rustdoc/src-links-auto-impls.rs +++ b/src/test/rustdoc/src-links-auto-impls.rs @@ -2,11 +2,11 @@ // @has foo/struct.Unsized.html // @has - '//div[@id="impl-Sized"]/code' 'impl !Sized for Unsized' -// @!has - '//div[@id="impl-Sized"]/a[@class="srclink"]' '[src]' +// @!has - '//div[@id="impl-Sized"]//a[@class="srclink"]' '[src]' // @has - '//div[@id="impl-Sync"]/code' 'impl Sync for Unsized' -// @!has - '//div[@id="impl-Sync"]/a[@class="srclink"]' '[src]' +// @!has - '//div[@id="impl-Sync"]//a[@class="srclink"]' '[src]' // @has - '//div[@id="impl-Any"]/code' 'impl<T> Any for T' -// @has - '//div[@id="impl-Any"]/a[@class="srclink"]' '[src]' +// @has - '//div[@id="impl-Any"]//a[@class="srclink"]' '[src]' pub struct Unsized { data: [u8], } |
