Skip to content

Commit b7daf4a

Browse files
Overload new source page sidebar button position
1 parent fc34b6a commit b7daf4a

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/utils/rustc_version.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ pub(crate) fn parse_rustc_date<S: AsRef<str>>(version: S) -> Result<NaiveDate> {
4444
/// generate this version of this crate.
4545
pub fn get_correct_docsrs_style_file(version: &str) -> Result<String> {
4646
let date = parse_rustc_date(version)?;
47+
// This is the date where https://github.com/rust-lang/rust/pull/144476 was merged.
48+
if NaiveDate::from_ymd_opt(2025, 8, 20).unwrap() < date {
49+
Ok("rustdoc-2025-08-20.css".to_owned())
4750
// This is the date where https://github.com/rust-lang/rust/pull/91356 was merged.
48-
if NaiveDate::from_ymd_opt(2021, 12, 5).unwrap() < date {
51+
} else if NaiveDate::from_ymd_opt(2021, 12, 5).unwrap() < date {
4952
// If this is the new rustdoc layout, we need the newer docs.rs CSS file.
5053
Ok("rustdoc-2021-12-05.css".to_owned())
5154
} else {

src/web/statics.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ const STYLE_CSS: &str = include_str!(concat!(env!("OUT_DIR"), "/style.css"));
1616
const RUSTDOC_CSS: &str = include_str!(concat!(env!("OUT_DIR"), "/rustdoc.css"));
1717
const RUSTDOC_2021_12_05_CSS: &str =
1818
include_str!(concat!(env!("OUT_DIR"), "/rustdoc-2021-12-05.css"));
19+
const RUSTDOC_2025_08_20_CSS: &str =
20+
include_str!(concat!(env!("OUT_DIR"), "/rustdoc-2025-08-20.css"));
1921

2022
fn build_static_css_response(content: &'static str) -> impl IntoResponse {
2123
(
@@ -67,6 +69,10 @@ pub(crate) fn build_static_router() -> AxumRouter {
6769
"/rustdoc-2021-12-05.css",
6870
get_static(|| async { build_static_css_response(RUSTDOC_2021_12_05_CSS) }),
6971
)
72+
.route(
73+
"/rustdoc-2025-08-20.css",
74+
get_static(|| async { build_static_css_response(RUSTDOC_2025_08_20_CSS) }),
75+
)
7076
.fallback_service(
7177
get_service(ServeDir::new("static").fallback(ServeDir::new("vendor")))
7278
.layer(middleware::from_fn(set_needed_static_headers))
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@import "rustdoc-2021-12-05";
2+
3+
// This file is needed to overload the previous docs.rs style. It is added into crates generated
4+
// using rustdoc after https://github.com/rust-lang/rust/pull/144476 has been merged.
5+
6+
.rustdoc.src {
7+
#sidebar-button {
8+
top: calc(8px + #{$top-navbar-height});
9+
}
10+
}

0 commit comments

Comments
 (0)