From 8a35cc3ddc5b18303d67d0455fa1a8fa88ca0af8 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 18 May 2023 16:16:13 +0200 Subject: Move item kind before the item name --- src/librustdoc/html/static/css/rustdoc.css | 5 +++++ src/librustdoc/html/static/js/search.js | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src/librustdoc/html') diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index b487cfa5c25..d469b397dcf 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -190,6 +190,7 @@ h1, h2, h3, h4, h5, h6, .mobile-topbar, .search-input, .search-results .result-name, +.search-results .type-kind, .item-name > a, .out-of-band, span.since, @@ -870,6 +871,10 @@ so that we can apply CSS-filters to change the arrow color in themes */ } .search-results > a > div { + flex: 3; +} + +.search-results > a > div.type-kind { flex: 1; } diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index f65d3915124..c25c36994fa 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -1866,7 +1866,7 @@ function initSearch(rawSearchIndex) { const name = item.name; const type = itemTypes[item.ty]; const longType = longItemTypes[item.ty]; - let extra = longType.length !== 0 ? ` (${longType})` : ""; + const typeName = longType.length !== 0 ? `${longType}` : "?"; length += 1; @@ -1878,7 +1878,6 @@ function initSearch(rawSearchIndex) { resultName.className = "result-name"; if (item.is_alias) { - extra = ""; const alias = document.createElement("span"); alias.className = "alias"; @@ -1892,9 +1891,15 @@ function initSearch(rawSearchIndex) { resultName.appendChild(alias); } + + const typeDisplay = document.createElement("div"); + typeDisplay.innerText = typeName; + typeDisplay.className = "type-kind"; + link.appendChild(typeDisplay); + resultName.insertAdjacentHTML( "beforeend", - item.displayPath + "" + name + "" + extra); + item.displayPath + "" + name + ""); link.appendChild(resultName); const description = document.createElement("div"); -- cgit 1.4.1-3-g733a5