7
7
//! Everything here is basically just a shim around calling either `rustbook` or
8
8
//! `rustdoc`.
9
9
10
- use std:: ffi:: OsStr ;
11
10
use std:: fs;
12
11
use std:: io;
13
12
use std:: path:: { Path , PathBuf } ;
@@ -471,20 +470,21 @@ impl Step for Std {
471
470
builder. ensure ( SharedAssets { target : self . target } ) ;
472
471
}
473
472
474
- let index_page = builder. src . join ( "src/doc/index.md" ) . into_os_string ( ) ;
473
+ let index_page = builder
474
+ . src
475
+ . join ( "src/doc/index.md" )
476
+ . into_os_string ( )
477
+ . into_string ( )
478
+ . expect ( "non-utf8 paths are unsupported" ) ;
475
479
let mut extra_args = match self . format {
476
- DocumentationFormat :: HTML => vec ! [
477
- OsStr :: new( "--markdown-css" ) ,
478
- OsStr :: new( "rust.css" ) ,
479
- OsStr :: new( "--markdown-no-toc" ) ,
480
- OsStr :: new( "--index-page" ) ,
481
- & index_page,
482
- ] ,
483
- DocumentationFormat :: JSON => vec ! [ OsStr :: new( "--output-format" ) , OsStr :: new( "json" ) ] ,
480
+ DocumentationFormat :: HTML => {
481
+ vec ! [ "--markdown-css" , "rust.css" , "--markdown-no-toc" , "--index-page" , & index_page]
482
+ }
483
+ DocumentationFormat :: JSON => vec ! [ "--output-format" , "json" ] ,
484
484
} ;
485
485
486
486
if !builder. config . docs_minification {
487
- extra_args. push ( OsStr :: new ( "--disable-minification" ) ) ;
487
+ extra_args. push ( "--disable-minification" ) ;
488
488
}
489
489
490
490
doc_std ( builder, self . format , stage, target, & out, & extra_args, & self . crates ) ;
@@ -549,7 +549,7 @@ fn doc_std(
549
549
stage : u32 ,
550
550
target : TargetSelection ,
551
551
out : & Path ,
552
- extra_args : & [ & OsStr ] ,
552
+ extra_args : & [ & str ] ,
553
553
requested_crates : & [ String ] ,
554
554
) {
555
555
if builder. no_std ( target) == Some ( true ) {
@@ -574,24 +574,39 @@ fn doc_std(
574
574
// as a function parameter.
575
575
let out_dir = target_dir. join ( target. triple ) . join ( "doc" ) ;
576
576
577
- let mut cargo = builder. cargo ( compiler, Mode :: Std , SourceType :: InTree , target, "rustdoc " ) ;
577
+ let mut cargo = builder. cargo ( compiler, Mode :: Std , SourceType :: InTree , target, "doc " ) ;
578
578
compile:: std_cargo ( builder, target, compiler. stage , & mut cargo) ;
579
- cargo. arg ( "--target-dir" ) . arg ( & * target_dir. to_string_lossy ( ) ) . arg ( "-Zskip-rustdoc-fingerprint" ) ;
579
+ cargo
580
+ . arg ( "--no-deps" )
581
+ . arg ( "--target-dir" )
582
+ . arg ( & * target_dir. to_string_lossy ( ) )
583
+ . arg ( "-Zskip-rustdoc-fingerprint" )
584
+ . rustdocflag ( "-Z" )
585
+ . rustdocflag ( "unstable-options" )
586
+ . rustdocflag ( "--resource-suffix" )
587
+ . rustdocflag ( & builder. version ) ;
588
+ for arg in extra_args {
589
+ cargo. rustdocflag ( arg) ;
590
+ }
580
591
581
- for krate in requested_crates {
582
- cargo. arg ( "-p " ) . arg ( krate ) ;
592
+ if builder . config . library_docs_private_items {
593
+ cargo. rustdocflag ( "--document-private-items " ) . rustdocflag ( "--document-hidden-items" ) ;
583
594
}
584
595
585
- cargo
586
- . arg ( "--" )
587
- . arg ( "-Z" )
588
- . arg ( "unstable-options" )
589
- . arg ( "--resource-suffix" )
590
- . arg ( & builder. version )
591
- . args ( extra_args) ;
596
+ // HACK: because we use `--manifest-path library/sysroot/Cargo.toml`, cargo thinks we only want to document that specific crate, not its dependencies.
597
+ // Override its default.
598
+ let built_crates = if requested_crates. is_empty ( ) {
599
+ builder
600
+ . in_tree_crates ( "sysroot" , None )
601
+ . into_iter ( )
602
+ . map ( |krate| krate. name . to_string ( ) )
603
+ . collect ( )
604
+ } else {
605
+ requested_crates. to_vec ( )
606
+ } ;
592
607
593
- if builder . config . library_docs_private_items {
594
- cargo. arg ( "--document-private-items " ) . arg ( "--document-hidden-items" ) ;
608
+ for krate in built_crates {
609
+ cargo. arg ( "-p " ) . arg ( krate ) ;
595
610
}
596
611
597
612
builder. run ( & mut cargo. into ( ) ) ;
0 commit comments