From a8fa961696fcbdef7a74fdd80033c464c156f453 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Thu, 22 Jun 2023 12:16:48 -0700 Subject: [PATCH 1/5] Align search results horizontally for easy scanning The recent PR #110688 added info about an item's kind before its name in search results. However, because the kind and name are inline with no alignment, it's now hard to visually scan downward through the search results, looking at item names. This PR fixes that by horizontally aligning search results such that there are now two columns of information. --- src/librustdoc/html/static/css/rustdoc.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 21c1eb631e07b..83b989fc080d0 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -891,8 +891,10 @@ so that we can apply CSS-filters to change the arrow color in themes */ color: var(--search-results-grey-color); } .search-results .result-name .typename { + display: inline-block; color: var(--search-results-grey-color); font-size: 0.875rem; + width: 6rem; } .popover { From c4fca7202b83053f12e1f47ec0a44c01de2ec2aa Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Fri, 23 Jun 2023 09:51:53 -0700 Subject: [PATCH 2/5] Abbreviate long typenames so they don't get wrapped in results --- src/librustdoc/html/static/js/search.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 452348dc86507..b8cc0a6db714d 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -52,9 +52,9 @@ const longItemTypes = [ "enum variant", "macro", "primitive type", - "associated type", + "assoc type", "constant", - "associated constant", + "assoc const", "union", "foreign type", "keyword", From 12de5b7ff33fe37eb8ce5dd92efd1366e43e85aa Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Fri, 23 Jun 2023 10:12:27 -0700 Subject: [PATCH 3/5] Make typenames a bit wider to support "existential type" --- src/librustdoc/html/static/css/rustdoc.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 83b989fc080d0..b4ee3482de39a 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -894,7 +894,7 @@ so that we can apply CSS-filters to change the arrow color in themes */ display: inline-block; color: var(--search-results-grey-color); font-size: 0.875rem; - width: 6rem; + width: 7rem; } .popover { From 5f433f33ed8d4a8ede25c36d2bb0543e8b101920 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Fri, 23 Jun 2023 12:02:55 -0700 Subject: [PATCH 4/5] Reduce typename width to 6.25rem This makes "existential type" look slightly cramped (though still readable), but it makes all other typenames look better. Existential types are currently very rare, and we can always tweak this later if necessary. --- src/librustdoc/html/static/css/rustdoc.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index b4ee3482de39a..b6d90091bbaef 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -894,7 +894,7 @@ so that we can apply CSS-filters to change the arrow color in themes */ display: inline-block; color: var(--search-results-grey-color); font-size: 0.875rem; - width: 7rem; + width: 6.25rem; } .popover { From 9b97ae1d8c6e99a4832c84dec4d4b6faf5f583f6 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Sat, 24 Jun 2023 14:30:35 -0700 Subject: [PATCH 5/5] rustdoc: Update GUI test --- tests/rustdoc-gui/search-result-display.goml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/rustdoc-gui/search-result-display.goml b/tests/rustdoc-gui/search-result-display.goml index afb3a44be303f..6593c1a9c45a5 100644 --- a/tests/rustdoc-gui/search-result-display.goml +++ b/tests/rustdoc-gui/search-result-display.goml @@ -14,7 +14,8 @@ set-window-size: (600, 100) assert-size: (".search-results div.desc", {"width": 566}) // The result set is all on one line. -assert-css: (".search-results .result-name > span", {"display": "inline"}) +assert-css: (".search-results .result-name > span:not(.typename)", {"display": "inline"}) +assert-css: (".search-results .result-name > span.typename", {"display": "inline-block"}) // Check that the crate filter `