From fed059270a2fda61b7ea7393ed7b3f78d33fad32 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 17 Jul 2024 14:33:10 +0200 Subject: [PATCH 1/2] Wrap too long item name and improve the item list display a bit --- src/librustdoc/html/static/css/rustdoc.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index cb8b82e8bde0a..a305335e0b3e5 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -2174,6 +2174,14 @@ in src-script.js and main.js padding: 2px 4px; box-shadow: 0 0 4px var(--main-background-color); } + + .item-table > li > .item-name { + width: 33%; + } + .item-table > li > div { + padding-bottom: 5px; + word-break: break-all; + } } @media print { From c820a2392ce90722c2d8d0e1050b6194ac532b78 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 18 Jul 2024 20:48:10 +0200 Subject: [PATCH 2/2] Add test for size of items in the items list --- tests/rustdoc-gui/src/lib2/lib.rs | 1 + tests/rustdoc-gui/type-declation-overflow.goml | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/rustdoc-gui/src/lib2/lib.rs b/tests/rustdoc-gui/src/lib2/lib.rs index b467b04405233..2467c7adae1a3 100644 --- a/tests/rustdoc-gui/src/lib2/lib.rs +++ b/tests/rustdoc-gui/src/lib2/lib.rs @@ -117,6 +117,7 @@ pub mod too_long { pub type ReallyLongTypeNameLongLongLong = Option *const u8>; + /// Short doc. pub const ReallyLongTypeNameLongLongLongConstBecauseWhyNotAConstRightGigaGigaSupraLong: u32 = 0; /// This also has a really long doccomment. Lorem ipsum dolor sit amet, diff --git a/tests/rustdoc-gui/type-declation-overflow.goml b/tests/rustdoc-gui/type-declation-overflow.goml index 3709aa102661f..fdf84c3fd2950 100644 --- a/tests/rustdoc-gui/type-declation-overflow.goml +++ b/tests/rustdoc-gui/type-declation-overflow.goml @@ -16,7 +16,11 @@ assert-property: ("pre.item-decl", {"scrollWidth": "1324"}) // In the table-ish view on the module index, the name should not be wrapped more than necessary. go-to: "file://" + |DOC_PATH| + "/lib2/too_long/index.html" -assert-property: (".item-table .struct", {"offsetWidth": "684"}) + +// We'll ensure that items with short documentation have the same width. +store-property: ("//*[@class='item-table']//*[@class='struct']/..", {"offsetWidth": offset_width}) +assert: |offset_width| == "277" +assert-property: ("//*[@class='item-table']//*[@class='constant']/..", {"offsetWidth": |offset_width|}) // We now make the same check on type declaration... go-to: "file://" + |DOC_PATH| + "/lib2/too_long/type.ReallyLongTypeNameLongLongLong.html"