Skip to content

Commit 7c1bf86

Browse files
authored
Rollup merge of rust-lang#127418 - GuillaumeGomez:wrap-too-long-type-name, r=notriddle
Wrap too long type name Fixes rust-lang#120595. Takeover of rust-lang#126209. cc `@BradMarr` r? `@notriddle`
2 parents 5affbb1 + c820a23 commit 7c1bf86

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/librustdoc/html/static/css/rustdoc.css

+8
Original file line numberDiff line numberDiff line change
@@ -2174,6 +2174,14 @@ in src-script.js and main.js
21742174
padding: 2px 4px;
21752175
box-shadow: 0 0 4px var(--main-background-color);
21762176
}
2177+
2178+
.item-table > li > .item-name {
2179+
width: 33%;
2180+
}
2181+
.item-table > li > div {
2182+
padding-bottom: 5px;
2183+
word-break: break-all;
2184+
}
21772185
}
21782186

21792187
@media print {

tests/rustdoc-gui/src/lib2/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ pub mod too_long {
117117
pub type ReallyLongTypeNameLongLongLong =
118118
Option<unsafe extern "C" fn(a: *const u8, b: *const u8) -> *const u8>;
119119

120+
/// Short doc.
120121
pub const ReallyLongTypeNameLongLongLongConstBecauseWhyNotAConstRightGigaGigaSupraLong: u32 = 0;
121122

122123
/// This also has a really long doccomment. Lorem ipsum dolor sit amet,

tests/rustdoc-gui/type-declation-overflow.goml

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ assert-property: ("pre.item-decl", {"scrollWidth": "1324"})
1616

1717
// In the table-ish view on the module index, the name should not be wrapped more than necessary.
1818
go-to: "file://" + |DOC_PATH| + "/lib2/too_long/index.html"
19-
assert-property: (".item-table .struct", {"offsetWidth": "684"})
19+
20+
// We'll ensure that items with short documentation have the same width.
21+
store-property: ("//*[@class='item-table']//*[@class='struct']/..", {"offsetWidth": offset_width})
22+
assert: |offset_width| == "277"
23+
assert-property: ("//*[@class='item-table']//*[@class='constant']/..", {"offsetWidth": |offset_width|})
2024

2125
// We now make the same check on type declaration...
2226
go-to: "file://" + |DOC_PATH| + "/lib2/too_long/type.ReallyLongTypeNameLongLongLong.html"

0 commit comments

Comments
 (0)