Skip to content

Commit

Permalink
Rollup merge of rust-lang#93763 - jsha:re-space-empty-impls, r=Guilla…
Browse files Browse the repository at this point in the history
…umeGomez

rustdoc: fix spacing of non-toggled impl blocks

We [recently removed the "up here" arrows on item-infos](rust-lang#92651), and adjusted
vertical spacing so that even without the arrow, it would be visually
clear which item the item-info belonged to. The new CSS styles for
vertical spacing only applied to toggles, though. This missed
non-toggled impl blocks - for instance, those without any methods, like
https://doc.rust-lang.org/nightly/std/marker/trait.Send.html#implementors.
The result was lists of implementors that were spaced too closely. This
PR fixes the spacing by making it apply to non-toggled impl blocks as
well.

This also fixes an issue where item-infos were displayed too far below
their items. That was a result of display: table on .item-info .stab.
Changed that to display: inline-block.

Demo: https://rustdoc.crud.net/jsha/re-space-empty-impls/std/marker/trait.Send.html

Before:

<img width=300 src="https://user-images.githubusercontent.com/220205/152954394-ec0b80e7-2573-4f06-9d7a-7b10b8ceac60.png">

After:

<img width=300 src="https://user-images.githubusercontent.com/220205/152954228-abac1d30-a76d-4ab1-89ec-ef7549fe8c9c.png">

r? `@GuillaumeGomez`
  • Loading branch information
matthiaskrgr committed Feb 9, 2022
2 parents a0cdc78 + 7806454 commit 2184cf7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ body.blur > :not(#help) {
}

.item-info .stab {
display: table;
display: inline-block;
}
.stab {
padding: 3px;
Expand Down Expand Up @@ -2039,7 +2039,8 @@ details.rustdoc-toggle[open] > summary.hideme::after {
}

.method-toggle summary,
.implementors-toggle summary {
.implementors-toggle summary,
.impl {
margin-bottom: 0.75em;
}

Expand Down
4 changes: 4 additions & 0 deletions src/test/rustdoc-gui/implementors.goml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ assert: ("#implementors-list .impl:nth-child(2) > a.anchor")
assert-attribute: ("#implementors-list .impl:nth-child(2)", {"id": "impl-Whatever-1"})
assert-attribute: ("#implementors-list .impl:nth-child(2) > a.anchor", {"href": "#impl-Whatever-1"})
assert: "#implementors-list .impl:nth-child(2) > .code-header.in-band"

goto: file://|DOC_PATH|/test_docs/struct.HasEmptyTraits.html
compare-elements-position-near-false: ("#impl-EmptyTrait1", "#impl-EmptyTrait2", {"y": 30})
compare-elements-position-near: ("#impl-EmptyTrait3 h3", "#impl-EmptyTrait3 .item-info", {"y": 30})
4 changes: 4 additions & 0 deletions src/test/rustdoc-gui/src/test_docs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ build = "build.rs"

[lib]
path = "lib.rs"

[features]
default = ["some-feature"]
some-feature = []
11 changes: 11 additions & 0 deletions src/test/rustdoc-gui/src/test_docs/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,14 @@ impl HeavilyDocumentedUnion {
macro_rules! heavily_documented_macro {
() => {};
}

pub trait EmptyTrait1 {}
pub trait EmptyTrait2 {}
pub trait EmptyTrait3 {}

pub struct HasEmptyTraits{}

impl EmptyTrait1 for HasEmptyTraits {}
impl EmptyTrait2 for HasEmptyTraits {}
#[doc(cfg(feature = "some-feature"))]
impl EmptyTrait3 for HasEmptyTraits {}

0 comments on commit 2184cf7

Please sign in to comment.