Skip to content

Commit cd3f4da

Browse files
Add rustdoc version into the help popup
1 parent e0c38af commit cd3f4da

File tree

6 files changed

+39
-13
lines changed

6 files changed

+39
-13
lines changed

Diff for: src/librustdoc/html/render/write_shared.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,18 @@ pub(super) fn write_shared(
268268
// Maybe we can change the representation to move this out of main.js?
269269
write_minify(
270270
"main.js",
271-
static_files::MAIN_JS.replace(
272-
"/* INSERT THEMES HERE */",
273-
&format!(" = {}", serde_json::to_string(&themes).unwrap()),
274-
),
271+
static_files::MAIN_JS
272+
.replace(
273+
"/* INSERT THEMES HERE */",
274+
&format!(" = {}", serde_json::to_string(&themes).unwrap()),
275+
)
276+
.replace(
277+
"/* INSERT RUSTDOC_VERSION HERE */",
278+
&format!(
279+
"rustdoc {}",
280+
rustc_interface::util::version_str().unwrap_or("unknown version")
281+
),
282+
),
275283
cx,
276284
options,
277285
)?;

Diff for: src/librustdoc/html/static/css/rustdoc.css

+12-3
Original file line numberDiff line numberDiff line change
@@ -928,15 +928,24 @@ body.blur > :not(#help) {
928928
display: block;
929929
margin-right: 0.5rem;
930930
}
931-
#help > div > span {
931+
#help span.top, #help span.bottom {
932932
text-align: center;
933933
display: block;
934-
margin: 10px 0;
935934
font-size: 18px;
936-
border-bottom: 1px solid #ccc;
935+
936+
}
937+
#help span.top {
938+
text-align: center;
939+
display: block;
940+
margin: 10px 0;
941+
border-bottom: 1px solid;
937942
padding-bottom: 4px;
938943
margin-bottom: 6px;
939944
}
945+
#help span.bottom {
946+
clear: both;
947+
border-top: 1px solid;
948+
}
940949
#help dd { margin: 5px 35px; }
941950
#help .infos { padding-left: 0; }
942951
#help h1, #help h2 { margin-top: 0; }

Diff for: src/librustdoc/html/static/css/themes/ayu.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ details.undocumented > summary::before {
286286
border-radius: 4px;
287287
}
288288

289-
#help > div > span {
290-
border-bottom-color: #5c6773;
289+
#help span.bottom, #help span.top {
290+
border-color: #5c6773;
291291
}
292292

293293
.since {

Diff for: src/librustdoc/html/static/css/themes/dark.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ details.undocumented > summary::before {
242242
border-color: #bfbfbf;
243243
}
244244

245-
#help > div > span {
246-
border-bottom-color: #bfbfbf;
245+
#help span.bottom, #help span.top {
246+
border-color: #bfbfbf;
247247
}
248248

249249
#help dt {

Diff for: src/librustdoc/html/static/css/themes/light.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ details.undocumented > summary::before {
232232
border-color: #bfbfbf;
233233
}
234234

235-
#help > div > span {
236-
border-bottom-color: #bfbfbf;
235+
#help span.bottom, #help span.top {
236+
border-color: #bfbfbf;
237237
}
238238

239239
.since {

Diff for: src/librustdoc/html/static/js/main.js

+9
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,7 @@ function hideThemeButtonState() {
911911
});
912912

913913
var book_info = document.createElement("span");
914+
book_info.className = "top";
914915
book_info.innerHTML = "You can find more information in \
915916
<a href=\"https://doc.rust-lang.org/rustdoc/\">the rustdoc book</a>.";
916917

@@ -961,6 +962,14 @@ function hideThemeButtonState() {
961962
container.appendChild(div_shortcuts);
962963
container.appendChild(div_infos);
963964

965+
var rustdoc_version = document.createElement("span");
966+
rustdoc_version.className = "bottom";
967+
var rustdoc_version_code = document.createElement("code");
968+
rustdoc_version_code.innerText = "/* INSERT RUSTDOC_VERSION HERE */";
969+
rustdoc_version.appendChild(rustdoc_version_code);
970+
971+
container.appendChild(rustdoc_version);
972+
964973
popup.appendChild(container);
965974
insertAfter(popup, searchState.outputElement());
966975
// So that it's only built once and then it'll do nothing when called!

0 commit comments

Comments
 (0)