Skip to content

Commit dbff700

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

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/docbuilder/rustwide_builder.rs

+10
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use rustwide::toolchain::ToolchainError;
2222
use rustwide::{Build, Crate, Toolchain, Workspace, WorkspaceBuilder};
2323
use serde_json::Value;
2424
use std::collections::{HashMap, HashSet};
25+
use std::io::{self, Write};
2526
use std::path::Path;
2627
use std::sync::Arc;
2728

@@ -589,8 +590,17 @@ impl RustwideBuilder {
589590
rustdoc_flags.extend(vec![
590591
"--resource-suffix".to_string(),
591592
format!("-{}", parse_rustc_version(&self.rustc_version)?),
593+
"--html-before-content".to_string(),
594+
"docrs-version.html".to_string(),
595+
"--html-in-header".to_string(),
596+
"docsrs-in-header.html".to_string(),
592597
]);
593598

599+
let f = build.host_source_dir().join("docrs-version.html");
600+
std::fs::write(f, "<div id=\"docs-rustdoc-v1\"></div>").expect("failed");
601+
let f = build.host_source_dir().join("docsrs-in-header.html");
602+
std::fs::write(f, "<style>#rustdoc_body_wrapper{padding:0;}</style>").expect("failed");
603+
594604
let mut storage = LogStorage::new(LevelFilter::Info);
595605
storage.set_max_size(limits.max_log_size());
596606

templates/style/rustdoc.scss

+4-3
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
}

0 commit comments

Comments
 (0)