Skip to content

Commit aa84100

Browse files
Fix footer display following last rustdoc changes on the sidebar
1 parent 1dd2aee commit aa84100

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ fn compile_sass() -> Result<(), Box<dyn Error>> {
7878
// Compile rustdoc.scss -> rustdoc.css
7979
compile_sass_file("rustdoc", "rustdoc", &[])?;
8080
compile_sass_file("rustdoc-2021-12-05", "rustdoc-2021-12-05", &[])?;
81+
compile_sass_file("rustdoc-2021-12-14", "rustdoc-2021-12-14", &[])?;
8182

8283
// Compile vendored.scss -> vendored.css
8384
compile_sass_file(

src/utils/rustc_version.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ pub fn get_correct_docsrs_style_file(version: &str) -> Result<String> {
4747
if Utc.ymd(2021, 12, 5) < date {
4848
// If this is the new rustdoc layout, we need the newer docs.rs CSS file.
4949
Ok("rustdoc-2021-12-05.css".to_owned())
50+
}
51+
// This is the date where https://github.com/rust-lang/rust/pull/92692 was merged.
52+
else if Utc.ymd(2021, 12, 14) < date {
53+
Ok("rustdoc-2021-12-14.css".to_owned())
5054
} else {
5155
// By default, we return the old docs.rs CSS file.
5256
Ok("rustdoc.css".to_owned())
@@ -72,8 +76,12 @@ fn test_get_correct_docsrs_style_file() {
7276
"rustdoc.css"
7377
);
7478
assert_eq!(
75-
get_correct_docsrs_style_file("docsrs 0.2.0 (ba9ae23 2022-05-26)").unwrap(),
79+
get_correct_docsrs_style_file("docsrs 0.2.0 (ba9ae23 2021-12-06)").unwrap(),
7680
"rustdoc-2021-12-05.css"
7781
);
82+
assert_eq!(
83+
get_correct_docsrs_style_file("docsrs 0.2.0 (ba9ae23 2021-12-16)").unwrap(),
84+
"rustdoc-2021-12-14.css"
85+
);
7886
assert!(get_correct_docsrs_style_file("docsrs 0.2.0").is_err(),);
7987
}

src/web/statics.rs

+6
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_2021_12_14_CSS: &str =
20+
include_str!(concat!(env!("OUT_DIR"), "/rustdoc-2021-12-14.css"));
1921
const STATIC_SEARCH_PATHS: &[&str] = &["static", "vendor"];
2022

2123
pub(crate) fn static_handler(req: &mut Request) -> IronResult<Response> {
@@ -31,6 +33,10 @@ pub(crate) fn static_handler(req: &mut Request) -> IronResult<Response> {
3133
RUSTDOC_2021_12_05_CSS,
3234
ContentType("text/css".parse().unwrap()),
3335
),
36+
"rustdoc-2021-12-14.css" => serve_resource(
37+
RUSTDOC_2021_12_14_CSS,
38+
ContentType("text/css".parse().unwrap()),
39+
),
3440
file => serve_file(file)?,
3541
})
3642
}
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// FIXME: Use modules
2+
@import "rustdoc-common";
3+
4+
// This file is needed to overload the previous docs.rs style. It is added into crates generated
5+
// using rustdoc after https://github.com/rust-lang/rust/pull/92692 has been merged.
6+
7+
#rustdoc_body_wrapper {
8+
padding: 0;
9+
10+
.sidebar {
11+
margin-top: 0;
12+
top: $top-navbar-height;
13+
height: calc(100vh - $top-navbar-height);
14+
/* Since we use `overflow-wrap: anywhere;`, we never have the need for a X scrollbar... */
15+
overflow-x: hidden;
16+
17+
.sidebar-menu {
18+
top: $top-navbar-height;
19+
margin-bottom: $footer-height;
20+
}
21+
}
22+
23+
main {
24+
padding-bottom: 50px;
25+
}
26+
}
27+
28+
div.container-rustdoc {
29+
> .docs-rs-footer {
30+
bottom: 0;
31+
right: 0;
32+
left: 0;
33+
}
34+
}
35+
36+
div.rustdoc {
37+
#sidebar-toggle {
38+
top: 0;
39+
}
40+
}

0 commit comments

Comments
 (0)