Skip to content

Commit 4aa248e

Browse files
Handle rustdoc version when generating crate doc
1 parent dd6e72b commit 4aa248e

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

src/docbuilder/rustwide_builder.rs

+23
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,31 @@ impl RustwideBuilder {
589589
rustdoc_flags.extend(vec![
590590
"--resource-suffix".to_string(),
591591
format!("-{}", parse_rustc_version(&self.rustc_version)?),
592+
"--html-before-content".to_string(),
593+
"docrs-version.html".to_string(),
594+
"--html-in-header".to_string(),
595+
"docsrs-in-header.html".to_string(),
592596
]);
593597

598+
let f = build.host_source_dir().join("docrs-version.html");
599+
std::fs::write(f, "<div id=\"docs-rustdoc-v1\"></div>").expect("failed");
600+
let f = build.host_source_dir().join("docsrs-in-header.html");
601+
std::fs::write(f, "<style>\
602+
#rustdoc_body_wrapper {
603+
padding: 0;
604+
}
605+
div.container-rustdoc > .docs-rs-footer {
606+
bottom: 0;
607+
right: 0;
608+
}
609+
div.container-rustdoc:not(.source) > .docs-rs-footer {
610+
left: 200px;
611+
}
612+
div.rustdoc #sidebar-toggle {
613+
top: 0;
614+
}\
615+
</style>").expect("failed");
616+
594617
let mut storage = LogStorage::new(LevelFilter::Info);
595618
storage.set_max_size(limits.max_log_size());
596619

templates/style/rustdoc.scss

+11-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
// This rule is needed to be sure that the footer will always be at the bottom of the page.
55
#rustdoc_body_wrapper {
66
min-height: calc(100vh - #{$top-navbar-height + $footer-height + 2});
7-
padding: 0;
7+
}
88

9-
.sidebar {
9+
#rustdoc_body_wrapper {
10+
#docs-rustdoc-v1 ~ .sidebar {
1011
margin-top: 0;
1112
top: $top-navbar-height;
1213

@@ -15,7 +16,7 @@
1516
}
1617
}
1718

18-
main {
19+
#docs-rustdoc-v1 ~ main {
1920
padding-bottom: 50px;
2021
}
2122
}
@@ -33,8 +34,8 @@ div.container-rustdoc {
3334
text-align: left;
3435

3536
> .docs-rs-footer {
36-
bottom: 0;
37-
right: 0;
37+
bottom: -32px;
38+
right: -15px;
3839
width: unset;
3940
}
4041
}
@@ -45,7 +46,7 @@ div.container-rustdoc {
4546

4647
div.container-rustdoc:not(.source) {
4748
> .docs-rs-footer {
48-
left: 200px; // This is the left sidebar
49+
left: 185px; // This is the left sidebar
4950
}
5051

5152
// This is when the rustdoc sidebar "disappears" (for mobile mode).
@@ -125,6 +126,10 @@ div.rustdoc {
125126
top: $top-navbar-height;
126127
}
127128

129+
#sidebar-toggle {
130+
top: 62px;
131+
}
132+
128133
&:focus {
129134
outline: unset;
130135
}

0 commit comments

Comments
 (0)