@@ -12,6 +12,9 @@ use cargo::util::{CargoResult, Config, human, Filesystem};
12
12
use cargo:: sources:: SourceConfigMap ;
13
13
use cargo:: ops:: { self , Packages , DefaultExecutor } ;
14
14
15
+ use utils:: { get_current_versions, parse_rustc_version} ;
16
+ use error:: Result ;
17
+
15
18
use Metadata ;
16
19
17
20
@@ -23,7 +26,7 @@ use Metadata;
23
26
// idea is to make cargo to download
24
27
// and build a crate and its documentation
25
28
// 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 > {
27
30
let config = try!( Config :: default ( ) ) ;
28
31
let source_id = try!( SourceId :: crates_io ( & config) ) ;
29
32
@@ -55,6 +58,16 @@ pub fn build_doc(name: &str, vers: Option<&str>, target: Option<&str>) -> CargoR
55
58
env:: set_var ( "RUSTFLAGS" , rustc_args. join ( " " ) ) ;
56
59
}
57
60
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
+
58
71
let opts = ops:: CompileOptions {
59
72
config : & config,
60
73
jobs : None ,
@@ -72,7 +85,7 @@ pub fn build_doc(name: &str, vers: Option<&str>, target: Option<&str>) -> CargoR
72
85
& [ ] , false ,
73
86
& [ ] , false ) ,
74
87
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 ( ) ) ,
76
89
} ;
77
90
78
91
let ws = try!( Workspace :: ephemeral ( pkg, & config, Some ( Filesystem :: new ( target_dir) ) , false ) ) ;
0 commit comments