@@ -434,6 +434,7 @@ impl Step for SharedAssets {
434
434
pub struct Std {
435
435
pub stage : u32 ,
436
436
pub target : TargetSelection ,
437
+ pub format : DocumentationFormat ,
437
438
}
438
439
439
440
impl Step for Std {
@@ -446,7 +447,15 @@ impl Step for Std {
446
447
}
447
448
448
449
fn make_run ( run : RunConfig < ' _ > ) {
449
- run. builder . ensure ( Std { stage : run. builder . top_stage , target : run. target } ) ;
450
+ run. builder . ensure ( Std {
451
+ stage : run. builder . top_stage ,
452
+ target : run. target ,
453
+ format : if run. builder . config . cmd . json ( ) {
454
+ DocumentationFormat :: JSON
455
+ } else {
456
+ DocumentationFormat :: HTML
457
+ } ,
458
+ } ) ;
450
459
}
451
460
452
461
/// Compile all standard library documentation.
@@ -462,13 +471,16 @@ impl Step for Std {
462
471
builder. ensure ( SharedAssets { target : self . target } ) ;
463
472
464
473
let index_page = builder. src . join ( "src/doc/index.md" ) . into_os_string ( ) ;
465
- let mut extra_args = vec ! [
466
- OsStr :: new( "--markdown-css" ) ,
467
- OsStr :: new( "rust.css" ) ,
468
- OsStr :: new( "--markdown-no-toc" ) ,
469
- OsStr :: new( "--index-page" ) ,
470
- & index_page,
471
- ] ;
474
+ let mut extra_args = match self . format {
475
+ DocumentationFormat :: HTML => vec ! [
476
+ OsStr :: new( "--markdown-css" ) ,
477
+ OsStr :: new( "rust.css" ) ,
478
+ OsStr :: new( "--markdown-no-toc" ) ,
479
+ OsStr :: new( "--index-page" ) ,
480
+ & index_page,
481
+ ] ,
482
+ DocumentationFormat :: JSON => vec ! [ OsStr :: new( "--output-format" ) , OsStr :: new( "json" ) ] ,
483
+ } ;
472
484
473
485
if !builder. config . docs_minification {
474
486
extra_args. push ( OsStr :: new ( "--disable-minification" ) ) ;
@@ -492,15 +504,7 @@ impl Step for Std {
492
504
} )
493
505
. collect :: < Vec < _ > > ( ) ;
494
506
495
- doc_std (
496
- builder,
497
- DocumentationFormat :: HTML ,
498
- stage,
499
- target,
500
- & out,
501
- & extra_args,
502
- & requested_crates,
503
- ) ;
507
+ doc_std ( builder, self . format , stage, target, & out, & extra_args, & requested_crates) ;
504
508
505
509
// Look for library/std, library/core etc in the `x.py doc` arguments and
506
510
// open the corresponding rendered docs.
@@ -513,43 +517,6 @@ impl Step for Std {
513
517
}
514
518
}
515
519
516
- #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
517
- pub struct JsonStd {
518
- pub stage : u32 ,
519
- pub target : TargetSelection ,
520
- }
521
-
522
- impl Step for JsonStd {
523
- type Output = ( ) ;
524
- const DEFAULT : bool = false ;
525
-
526
- fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
527
- if run. builder . config . cmd . json ( ) {
528
- let default = run. builder . config . docs && run. builder . config . cmd . json ( ) ;
529
- run. all_krates ( "test" ) . path ( "library" ) . default_condition ( default)
530
- } else {
531
- // Without this JsonStd would take priority on Std and prevent it from running.
532
- run. never ( )
533
- }
534
- }
535
-
536
- fn make_run ( run : RunConfig < ' _ > ) {
537
- run. builder . ensure ( JsonStd { stage : run. builder . top_stage , target : run. target } ) ;
538
- }
539
-
540
- /// Build JSON documentation for the standard library crates.
541
- ///
542
- /// This is largely just a wrapper around `cargo doc`.
543
- fn run ( self , builder : & Builder < ' _ > ) {
544
- let stage = self . stage ;
545
- let target = self . target ;
546
- let out = builder. json_doc_out ( target) ;
547
- t ! ( fs:: create_dir_all( & out) ) ;
548
- let extra_args = [ OsStr :: new ( "--output-format" ) , OsStr :: new ( "json" ) ] ;
549
- doc_std ( builder, DocumentationFormat :: JSON , stage, target, & out, & extra_args, & [ ] )
550
- }
551
- }
552
-
553
520
/// Name of the crates that are visible to consumers of the standard library.
554
521
/// Documentation for internal crates is handled by the rustc step, so internal crates will show
555
522
/// up there.
@@ -562,7 +529,7 @@ impl Step for JsonStd {
562
529
const STD_PUBLIC_CRATES : [ & str ; 5 ] = [ "core" , "alloc" , "std" , "proc_macro" , "test" ] ;
563
530
564
531
#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
565
- enum DocumentationFormat {
532
+ pub enum DocumentationFormat {
566
533
HTML ,
567
534
JSON ,
568
535
}
0 commit comments