@@ -158,6 +158,10 @@ pub fn opts() -> Vec<RustcOptGroup> {
158
158
stable( "extern" , |o| {
159
159
o. optmulti( "" , "extern" , "pass an --extern to rustc" , "NAME=PATH" )
160
160
} ) ,
161
+ unstable( "extern-html-root-url" , |o| {
162
+ o. optmulti( "" , "extern-html-root-url" ,
163
+ "base URL to use for dependencies" , "NAME=URL" )
164
+ } ) ,
161
165
stable( "plugin-path" , |o| {
162
166
o. optmulti( "" , "plugin-path" , "directory to load plugins from" , "DIR" )
163
167
} ) ,
@@ -423,6 +427,13 @@ pub fn main_args(args: &[String]) -> isize {
423
427
return 1 ;
424
428
}
425
429
} ;
430
+ let extern_urls = match parse_extern_html_roots ( & matches) {
431
+ Ok ( ex) => ex,
432
+ Err ( err) => {
433
+ diag. struct_err ( err) . emit ( ) ;
434
+ return 1 ;
435
+ }
436
+ } ;
426
437
427
438
let test_args = matches. opt_strs ( "test-args" ) ;
428
439
let test_args: Vec < String > = test_args. iter ( )
@@ -521,7 +532,7 @@ pub fn main_args(args: &[String]) -> isize {
521
532
info ! ( "going to format" ) ;
522
533
match output_format. as_ref ( ) . map ( |s| & * * s) {
523
534
Some ( "html" ) | None => {
524
- html:: render:: run ( krate, & external_html, playground_url,
535
+ html:: render:: run ( krate, extern_urls , & external_html, playground_url,
525
536
output. unwrap_or ( PathBuf :: from ( "doc" ) ) ,
526
537
resource_suffix. unwrap_or ( String :: new ( ) ) ,
527
538
passes. into_iter ( ) . collect ( ) ,
@@ -580,6 +591,23 @@ fn parse_externs(matches: &getopts::Matches) -> Result<Externs, String> {
580
591
Ok ( Externs :: new ( externs) )
581
592
}
582
593
594
+ /// Extracts `--extern-html-root-url` arguments from `matches` and returns a map of crate names to
595
+ /// the given URLs. If an `--extern-html-root-url` argument was ill-formed, returns an error
596
+ /// describing the issue.
597
+ fn parse_extern_html_roots ( matches : & getopts:: Matches )
598
+ -> Result < BTreeMap < String , String > , & ' static str >
599
+ {
600
+ let mut externs = BTreeMap :: new ( ) ;
601
+ for arg in & matches. opt_strs ( "extern-html-root-url" ) {
602
+ let mut parts = arg. splitn ( 2 , '=' ) ;
603
+ let name = parts. next ( ) . ok_or ( "--extern-html-root-url must not be empty" ) ?;
604
+ let url = parts. next ( ) . ok_or ( "--extern-html-root-url must be of the form name=url" ) ?;
605
+ externs. insert ( name. to_string ( ) , url. to_string ( ) ) ;
606
+ }
607
+
608
+ Ok ( externs)
609
+ }
610
+
583
611
/// Interprets the input file as a rust source file, passing it through the
584
612
/// compiler all the way through the analysis passes. The rustdoc output is then
585
613
/// generated from the cleaned AST of the crate.
0 commit comments