Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b290aa2

Browse files
committedJan 22, 2022
Fix footer display following last rustdoc changes on the sidebar
1 parent 1dd2aee commit b290aa2

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
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-2022-01-19", "rustdoc-2022-01-19", &[])?;
8182

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

‎src/utils/rustc_version.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ fn parse_rustc_date<S: AsRef<str>>(version: S) -> Result<Date<Utc>> {
4343
/// generate this version of this crate.
4444
pub fn get_correct_docsrs_style_file(version: &str) -> Result<String> {
4545
let date = parse_rustc_date(version)?;
46+
// This is the date where https://github.com/rust-lang/rust/pull/92692 was merged.
47+
if Utc.ymd(2022, 1, 19) < date {
48+
Ok("rustdoc-2022-01-19.css".to_owned())
49+
}
4650
// This is the date where https://github.com/rust-lang/rust/pull/91356 was merged.
47-
if Utc.ymd(2021, 12, 5) < date {
51+
else if Utc.ymd(2021, 12, 5) < date {
4852
// If this is the new rustdoc layout, we need the newer docs.rs CSS file.
4953
Ok("rustdoc-2021-12-05.css".to_owned())
5054
} else {
@@ -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 2022-01-02)").unwrap(),
7680
"rustdoc-2021-12-05.css"
7781
);
82+
assert_eq!(
83+
get_correct_docsrs_style_file("docsrs 0.2.0 (ba9ae23 2022-05-26)").unwrap(),
84+
"rustdoc-2022-01-19.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_2022_01_19_CSS: &str =
20+
include_str!(concat!(env!("OUT_DIR"), "/rustdoc-2022-01-19.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-2022-01-19.css" => serve_resource(
37+
RUSTDOC_2022_01_19_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)
Please sign in to comment.