Skip to content

Commit

Permalink
Rollup merge of rust-lang#88964 - GuillaumeGomez:version-help, r=Nemo157
Browse files Browse the repository at this point in the history
Add rustdoc version into the help popup

After a discussion with a rustdoc user about a specific behaviour, we realized we were not talking about the same version. To add on top of it, it was actually not that simple to find out the version since it was hosted documentation.

So to simplify things, I added the version into the help popup:

![Screenshot from 2021-09-16 10-45-52](https://user-images.githubusercontent.com/3050060/133581128-b93b460a-e1cb-4a31-9f2f-97c7a916cfcc.png)

Does the version format looks or would you prefer that I add more information? We can also add the commit hash, commit date, host and release.

cc `@rust-lang/rustdoc`
r? `@jyn514`
  • Loading branch information
GuillaumeGomez authored Sep 17, 2021
2 parents eb62779 + cd3f4da commit 833358b
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 13 deletions.
16 changes: 12 additions & 4 deletions src/librustdoc/html/render/write_shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,18 @@ pub(super) fn write_shared(
// Maybe we can change the representation to move this out of main.js?
write_minify(
"main.js",
static_files::MAIN_JS.replace(
"/* INSERT THEMES HERE */",
&format!(" = {}", serde_json::to_string(&themes).unwrap()),
),
static_files::MAIN_JS
.replace(
"/* INSERT THEMES HERE */",
&format!(" = {}", serde_json::to_string(&themes).unwrap()),
)
.replace(
"/* INSERT RUSTDOC_VERSION HERE */",
&format!(
"rustdoc {}",
rustc_interface::util::version_str().unwrap_or("unknown version")
),
),
cx,
options,
)?;
Expand Down
15 changes: 12 additions & 3 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -928,15 +928,24 @@ body.blur > :not(#help) {
display: block;
margin-right: 0.5rem;
}
#help > div > span {
#help span.top, #help span.bottom {
text-align: center;
display: block;
margin: 10px 0;
font-size: 18px;
border-bottom: 1px solid #ccc;

}
#help span.top {
text-align: center;
display: block;
margin: 10px 0;
border-bottom: 1px solid;
padding-bottom: 4px;
margin-bottom: 6px;
}
#help span.bottom {
clear: both;
border-top: 1px solid;
}
#help dd { margin: 5px 35px; }
#help .infos { padding-left: 0; }
#help h1, #help h2 { margin-top: 0; }
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ details.undocumented > summary::before {
border-radius: 4px;
}

#help > div > span {
border-bottom-color: #5c6773;
#help span.bottom, #help span.top {
border-color: #5c6773;
}

.since {
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ details.undocumented > summary::before {
border-color: #bfbfbf;
}

#help > div > span {
border-bottom-color: #bfbfbf;
#help span.bottom, #help span.top {
border-color: #bfbfbf;
}

#help dt {
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ details.undocumented > summary::before {
border-color: #bfbfbf;
}

#help > div > span {
border-bottom-color: #bfbfbf;
#help span.bottom, #help span.top {
border-color: #bfbfbf;
}

.since {
Expand Down
9 changes: 9 additions & 0 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,7 @@ function hideThemeButtonState() {
});

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

Expand Down Expand Up @@ -961,6 +962,14 @@ function hideThemeButtonState() {
container.appendChild(div_shortcuts);
container.appendChild(div_infos);

var rustdoc_version = document.createElement("span");
rustdoc_version.className = "bottom";
var rustdoc_version_code = document.createElement("code");
rustdoc_version_code.innerText = "/* INSERT RUSTDOC_VERSION HERE */";
rustdoc_version.appendChild(rustdoc_version_code);

container.appendChild(rustdoc_version);

popup.appendChild(container);
insertAfter(popup, searchState.outputElement());
// So that it's only built once and then it'll do nothing when called!
Expand Down

0 comments on commit 833358b

Please sign in to comment.