Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions gui-tests/sidebar.goml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ assert-position: (".rustdoc .sidebar", {"y": |topbar_height|, "x": 0})

// We check the same in "mobile mode".
set-window-size: (600, 1000)
assert-position: (".rustdoc .mobile-topbar", {"y": |topbar_height|, "x": 0})
wait-for-css-false: ("rustdoc-topbar", {"display": "none"})
assert-position: ("rustdoc-topbar", {"y": |topbar_height|, "x": 0})
// We check when the sidebar is shown now.
click: ".rustdoc .mobile-topbar .sidebar-menu-toggle"
click: "rustdoc-topbar .sidebar-menu-toggle"
wait-for: ".rustdoc .sidebar.shown"
// The mobile sidebar is supposed to be under the rustdoc mobile topbar + docs.rs topbar.
store-size: (".rustdoc .mobile-topbar", {"height": rustdoc_topbar_height})
store-size: ("rustdoc-topbar", {"height": rustdoc_topbar_height})
assert-position: (".rustdoc .sidebar.shown", {
"y": |topbar_height| + |rustdoc_topbar_height|,
"x": 0,
Expand All @@ -27,8 +28,8 @@ set-window-size: (1000, 1000)
wait-for: ".main-heading a.src"
click: ".main-heading a.src"

// We wait for the page to load...
wait-for: ".rustdoc.src"
// We wait for the page to load (by waiting for the sidebar to be filled)...
wait-for: "#src-sidebar"
// We check that the sidebar has the correct position.
assert-position: (".rustdoc .sidebar", {"y": |topbar_height|, "x": 0})
// We expand the sidebar.
Expand Down
2 changes: 1 addition & 1 deletion gui-tests/theme.goml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// the crate page we control the whole page

go-to: |DOC_PATH| + "/sysinfo"
set-local-storage: { "rustdoc-theme": null }
set-local-storage: { "rustdoc-theme": "light" }
wait-for-css: (".nav-container", { "background-color": "rgb(255, 255, 255)" })
go-to: |DOC_PATH| + "/crate/sysinfo"
wait-for-css: ("body", { "background-color": "rgb(255, 255, 255)" })
Expand Down
5 changes: 4 additions & 1 deletion src/utils/rustc_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ pub(crate) fn parse_rustc_date<S: AsRef<str>>(version: S) -> Result<NaiveDate> {
/// generate this version of this crate.
pub fn get_correct_docsrs_style_file(version: &str) -> Result<String> {
let date = parse_rustc_date(version)?;
// This is the date where https://github.com/rust-lang/rust/pull/144476 was merged.
if NaiveDate::from_ymd_opt(2025, 8, 20).unwrap() < date {
Ok("rustdoc-2025-08-20.css".to_owned())
// This is the date where https://github.com/rust-lang/rust/pull/91356 was merged.
if NaiveDate::from_ymd_opt(2021, 12, 5).unwrap() < date {
} else if NaiveDate::from_ymd_opt(2021, 12, 5).unwrap() < date {
// If this is the new rustdoc layout, we need the newer docs.rs CSS file.
Ok("rustdoc-2021-12-05.css".to_owned())
} else {
Expand Down
6 changes: 6 additions & 0 deletions src/web/statics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const STYLE_CSS: &str = include_str!(concat!(env!("OUT_DIR"), "/style.css"));
const RUSTDOC_CSS: &str = include_str!(concat!(env!("OUT_DIR"), "/rustdoc.css"));
const RUSTDOC_2021_12_05_CSS: &str =
include_str!(concat!(env!("OUT_DIR"), "/rustdoc-2021-12-05.css"));
const RUSTDOC_2025_08_20_CSS: &str =
include_str!(concat!(env!("OUT_DIR"), "/rustdoc-2025-08-20.css"));

fn build_static_css_response(content: &'static str) -> impl IntoResponse {
(
Expand Down Expand Up @@ -67,6 +69,10 @@ pub(crate) fn build_static_router() -> AxumRouter {
"/rustdoc-2021-12-05.css",
get_static(|| async { build_static_css_response(RUSTDOC_2021_12_05_CSS) }),
)
.route(
"/rustdoc-2025-08-20.css",
get_static(|| async { build_static_css_response(RUSTDOC_2025_08_20_CSS) }),
)
.fallback_service(
get_service(ServeDir::new("static").fallback(ServeDir::new("vendor")))
.layer(middleware::from_fn(set_needed_static_headers))
Expand Down
10 changes: 10 additions & 0 deletions templates/style/rustdoc-2025-08-20.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@import "rustdoc-2021-12-05";

// This file is needed to overload the previous docs.rs style. It is added into crates generated
// using rustdoc after https://github.com/rust-lang/rust/pull/144476 has been merged.

.rustdoc.src {
#sidebar-button {
top: calc(8px + #{$top-navbar-height});
}
}
Loading