Skip to content

Commit deee6f7

Browse files
authored
Rollup merge of #92830 - jsha:style-cleanups, r=GuillaumeGomez
Rustdoc style cleanups - Make "since" version numbers grey again (regressed in #92602). - Remove unneeded selectors for when crate filter dropdown is a sibling of search-input. - Crate filter dropdown doesn't need to be 100% width on mobile. - Only build crate filter dropdown when there is more than one crate. - Remove unused addCrateDropdown Demo: https://rustdoc.crud.net/jsha/style-cleanups/std/string/struct.String.html r? `@GuillaumeGomez`
2 parents cc2339c + ae99e23 commit deee6f7

File tree

10 files changed

+62
-41
lines changed

10 files changed

+62
-41
lines changed

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

-6
Original file line numberDiff line numberDiff line change
@@ -944,11 +944,6 @@ h2.small-section-header > .anchor {
944944
width: 100%;
945945
}
946946

947-
#crate-search + .search-input {
948-
border-radius: 0 1px 1px 0;
949-
width: calc(100% - 32px);
950-
}
951-
952947
.search-input:focus {
953948
border-radius: 2px;
954949
border: 0;
@@ -2081,7 +2076,6 @@ details.rustdoc-toggle[open] > summary.hideme::after {
20812076
}
20822077

20832078
#crate-search {
2084-
width: 100%;
20852079
border-radius: 4px;
20862080
border: 0;
20872081
}

src/librustdoc/html/static/css/themes/ayu.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ details.undocumented > summary::before {
299299
border-color: #5c6773;
300300
}
301301

302-
.since {
302+
.rightside,
303+
.out-of-band {
303304
color: grey;
304305
}
305306

src/librustdoc/html/static/css/themes/dark.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ details.undocumented > summary::before {
256256
background: rgba(0,0,0,0);
257257
}
258258

259-
.since {
259+
.rightside,
260+
.out-of-band {
260261
color: grey;
261262
}
262263

src/librustdoc/html/static/css/themes/light.css

+5
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ details.undocumented > summary::before {
243243
border-color: #bfbfbf;
244244
}
245245

246+
.rightside,
247+
.out-of-band {
248+
color: grey;
249+
}
250+
246251
.result-name .primitive > i, .result-name .keyword > i {
247252
color: black;
248253
}

src/librustdoc/html/static/js/main.js

-27
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,6 @@ function hideThemeButtonState() {
288288
loadSearch();
289289
}
290290

291-
// `crates{version}.js` should always be loaded before this script, so we can use it
292-
// safely.
293-
searchState.addCrateDropdown(window.ALL_CRATES);
294291
var params = searchState.getQueryStringParams();
295292
if (params.search !== undefined) {
296293
var search = searchState.outputElement();
@@ -300,30 +297,6 @@ function hideThemeButtonState() {
300297
loadSearch();
301298
}
302299
},
303-
addCrateDropdown: function(crates) {
304-
var elem = document.getElementById("crate-search");
305-
306-
if (!elem) {
307-
return;
308-
}
309-
var savedCrate = getSettingValue("saved-filter-crate");
310-
for (var i = 0, len = crates.length; i < len; ++i) {
311-
var option = document.createElement("option");
312-
option.value = crates[i];
313-
option.innerText = crates[i];
314-
elem.appendChild(option);
315-
// Set the crate filter from saved storage, if the current page has the saved crate
316-
// filter.
317-
//
318-
// If not, ignore the crate filter -- we want to support filtering for crates on
319-
// sites like doc.rust-lang.org where the crates may differ from page to page while
320-
// on the
321-
// same domain.
322-
if (crates[i] === savedCrate) {
323-
elem.value = savedCrate;
324-
}
325-
}
326-
},
327300
};
328301

329302
function getPageId() {

src/librustdoc/html/static/js/search.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -1126,15 +1126,18 @@ window.initSearch = function(rawSearchIndex) {
11261126
}
11271127
}
11281128

1129-
let crates = `<select id="crate-search"><option value="All crates">All crates</option>`;
1130-
for (let c of window.ALL_CRATES) {
1131-
crates += `<option value="${c}" ${c == filterCrates && "selected"}>${c}</option>`;
1129+
let crates = "";
1130+
if (window.ALL_CRATES.length > 1) {
1131+
crates = ` in <select id="crate-search"><option value="All crates">All crates</option>`;
1132+
for (let c of window.ALL_CRATES) {
1133+
crates += `<option value="${c}" ${c == filterCrates && "selected"}>${c}</option>`;
1134+
}
1135+
crates += `</select>`;
11321136
}
1133-
crates += `</select>`;
11341137
var output = `<div id="search-settings">
11351138
<h1 class="search-results-title">Results for ${escape(query.query)} ` +
11361139
(query.type ? " (type: " + escape(query.type) + ")" : "") + "</h1>" +
1137-
` in ${crates} ` +
1140+
crates +
11381141
`</div><div id="titles">` +
11391142
makeTabHeader(0, "In Names", ret_others[1]) +
11401143
makeTabHeader(1, "In Parameters", ret_in_args[1]) +
@@ -1148,7 +1151,10 @@ window.initSearch = function(rawSearchIndex) {
11481151
resultsElem.appendChild(ret_returned[0]);
11491152

11501153
search.innerHTML = output;
1151-
document.getElementById("crate-search").addEventListener("input", updateCrate);
1154+
let crateSearch = document.getElementById("crate-search");
1155+
if (crateSearch) {
1156+
crateSearch.addEventListener("input", updateCrate);
1157+
}
11521158
search.appendChild(resultsElem);
11531159
// Reset focused elements.
11541160
searchState.focusedByTab = [null, null, null];

src/test/rustdoc-gui/headings.goml

+13
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,16 @@ assert-css: ("h2#top-doc-prose-title", {"font-size": "20.8px"})
154154
assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"})
155155
assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "18.4px"})
156156
assert-css: ("h3#top-doc-prose-sub-heading", {"border-bottom-width": "1px"})
157+
158+
goto: file://|DOC_PATH|/staged_api/struct.Foo.html
159+
show-text: true
160+
local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
161+
assert-css: (".since", {"color": "rgb(128, 128, 128)"})
162+
163+
local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
164+
reload:
165+
assert-css: (".since", {"color": "rgb(128, 128, 128)"})
166+
167+
local-storage: {"rustdoc-theme": "ayu", "rustdoc-use-system-theme": "false"}
168+
reload:
169+
assert-css: (".since", {"color": "rgb(128, 128, 128)"})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file is automatically @generated by Cargo.
2+
# It is not intended for manual editing.
3+
version = 3
4+
5+
[[package]]
6+
name = "staged_api"
7+
version = "0.1.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "staged_api"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[lib]
7+
path = "lib.rs"
8+
9+
[features]
10+
default = ["some_feature"]
11+
some_feature = []
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![feature(staged_api)]
2+
#![stable(feature = "some_feature", since = "1.3.5")]
3+
4+
#[stable(feature = "some_feature", since = "1.3.5")]
5+
pub struct Foo {}
6+
7+
impl Foo {
8+
#[stable(feature = "some_feature", since = "1.3.5")]
9+
pub fn bar() {}
10+
}

0 commit comments

Comments
 (0)