Skip to content

Commit 0d936f0

Browse files
Fix new sidebar changes
1 parent 6e354ec commit 0d936f0

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ fn compile_sass() -> Result<(), Box<dyn Error>> {
7777

7878
// Compile rustdoc.scss -> rustdoc.css
7979
compile_sass_file("rustdoc", "rustdoc", &[])?;
80+
compile_sass_file("rustdoc-docsrs-1", "rustdoc-docsrs-1", &[])?;
8081

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

src/docbuilder/rustwide_builder.rs

+10
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,18 @@ impl RustwideBuilder {
589589
rustdoc_flags.extend(vec![
590590
"--resource-suffix".to_string(),
591591
format!("-{}", parse_rustc_version(&self.rustc_version)?),
592+
"--html-in-header".to_string(),
593+
"docsrs-in-header.html".to_string(),
592594
]);
593595

596+
let f = build.host_source_dir().join("docsrs-in-header.html");
597+
std::fs::write(
598+
f,
599+
"<link rel=\"stylesheet\" href=\"/-/static/rustdoc-docsrs-1.css\" \
600+
type=\"text/css\" media=\"all\">",
601+
)
602+
.expect("failed");
603+
594604
let mut storage = LogStorage::new(LevelFilter::Info);
595605
storage.set_max_size(limits.max_log_size());
596606

src/web/statics.rs

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::{ffi::OsStr, fs, path::Path};
1414
const VENDORED_CSS: &str = include_str!(concat!(env!("OUT_DIR"), "/vendored.css"));
1515
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"));
17+
const RUSTDOC_CSS_DOCSRS: &str = include_str!(concat!(env!("OUT_DIR"), "/rustdoc-docsrs-1.css"));
1718
const STATIC_SEARCH_PATHS: &[&str] = &["static", "vendor"];
1819

1920
pub(crate) fn static_handler(req: &mut Request) -> IronResult<Response> {
@@ -25,6 +26,7 @@ pub(crate) fn static_handler(req: &mut Request) -> IronResult<Response> {
2526
"vendored.css" => serve_resource(VENDORED_CSS, ContentType("text/css".parse().unwrap())),
2627
"style.css" => serve_resource(STYLE_CSS, ContentType("text/css".parse().unwrap())),
2728
"rustdoc.css" => serve_resource(RUSTDOC_CSS, ContentType("text/css".parse().unwrap())),
29+
"rustdoc-docsrs-1.css" => serve_resource(RUSTDOC_CSS_DOCSRS, ContentType("text/css".parse().unwrap())),
2830
file => serve_file(file)?,
2931
})
3032
}

templates/style/rustdoc-docsrs-1.scss

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
@import "vars";
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/91356 has been merged.
5+
6+
#rustdoc_body_wrapper {
7+
padding: 0 !important;
8+
9+
.sidebar {
10+
margin-top: 0 !important;
11+
top: $top-navbar-height !important;
12+
13+
.sidebar-menu {
14+
top: $top-navbar-height !important;
15+
}
16+
}
17+
18+
main {
19+
padding-bottom: 50px !important;
20+
}
21+
}
22+
23+
div.container-rustdoc > .docs-rs-footer {
24+
bottom: 0 !important;
25+
right: 0 !important;
26+
}
27+
28+
div.container-rustdoc:not(.source) > .docs-rs-footer {
29+
left: 200px !important;
30+
}
31+
32+
div.rustdoc #sidebar-toggle {
33+
top: 0 !important;
34+
}

0 commit comments

Comments
 (0)