Skip to content

Commit 8f96c2f

Browse files
committed
Pass --resource-suffix to rustdoc when building doc
1 parent 16475e7 commit 8f96c2f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/utils/build_doc.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ use cargo::util::{CargoResult, Config, human, Filesystem};
1212
use cargo::sources::SourceConfigMap;
1313
use cargo::ops::{self, Packages, DefaultExecutor};
1414

15+
use utils::{get_current_versions, parse_rustc_version};
16+
use error::Result;
17+
1518
use Metadata;
1619

1720

@@ -23,7 +26,7 @@ use Metadata;
2326
// idea is to make cargo to download
2427
// and build a crate and its documentation
2528
// instead of doing it manually like in the previous version of cratesfyi
26-
pub fn build_doc(name: &str, vers: Option<&str>, target: Option<&str>) -> CargoResult<Package> {
29+
pub fn build_doc(name: &str, vers: Option<&str>, target: Option<&str>) -> Result<Package> {
2730
let config = try!(Config::default());
2831
let source_id = try!(SourceId::crates_io(&config));
2932

@@ -55,6 +58,16 @@ pub fn build_doc(name: &str, vers: Option<&str>, target: Option<&str>) -> CargoR
5558
env::set_var("RUSTFLAGS", rustc_args.join(" "));
5659
}
5760

61+
// since https://github.com/rust-lang/rust/pull/48511 we can pass --resource-suffix to
62+
// add correct version numbers to css and javascript files
63+
let mut rustdoc_args: Vec<String> =
64+
vec!["-Z".to_string(), "unstable-options".to_string(),
65+
"--resource-suffix".to_string(),
66+
format!("-{}", parse_rustc_version(get_current_versions()?.0)?)];
67+
if let Some(package_rustdoc_args) = metadata.rustdoc_args {
68+
rustdoc_args.append(&mut package_rustdoc_args.iter().map(|s| s.to_owned()).collect());
69+
}
70+
5871
let opts = ops::CompileOptions {
5972
config: &config,
6073
jobs: None,
@@ -72,7 +85,7 @@ pub fn build_doc(name: &str, vers: Option<&str>, target: Option<&str>) -> CargoR
7285
&[], false,
7386
&[], false),
7487
target_rustc_args: None,
75-
target_rustdoc_args: metadata.rustdoc_args.as_ref().map(Vec::as_slice),
88+
target_rustdoc_args: Some(rustdoc_args.as_slice()),
7689
};
7790

7891
let ws = try!(Workspace::ephemeral(pkg, &config, Some(Filesystem::new(target_dir)), false));

0 commit comments

Comments
 (0)