@@ -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,12 @@ 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) ;
508
+
509
+ // Don't open if the format is json
510
+ if let DocumentationFormat :: JSON = self . format {
511
+ return ;
512
+ }
504
513
505
514
// Look for library/std, library/core etc in the `x.py doc` arguments and
506
515
// open the corresponding rendered docs.
@@ -513,38 +522,6 @@ impl Step for Std {
513
522
}
514
523
}
515
524
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
- let default = run. builder . config . docs && run. builder . config . cmd . json ( ) ;
528
- run. all_krates ( "test" ) . path ( "library" ) . default_condition ( default)
529
- }
530
-
531
- fn make_run ( run : RunConfig < ' _ > ) {
532
- run. builder . ensure ( Std { stage : run. builder . top_stage , target : run. target } ) ;
533
- }
534
-
535
- /// Build JSON documentation for the standard library crates.
536
- ///
537
- /// This is largely just a wrapper around `cargo doc`.
538
- fn run ( self , builder : & Builder < ' _ > ) {
539
- let stage = self . stage ;
540
- let target = self . target ;
541
- let out = builder. json_doc_out ( target) ;
542
- t ! ( fs:: create_dir_all( & out) ) ;
543
- let extra_args = [ OsStr :: new ( "--output-format" ) , OsStr :: new ( "json" ) ] ;
544
- doc_std ( builder, DocumentationFormat :: JSON , stage, target, & out, & extra_args, & [ ] )
545
- }
546
- }
547
-
548
525
/// Name of the crates that are visible to consumers of the standard library.
549
526
/// Documentation for internal crates is handled by the rustc step, so internal crates will show
550
527
/// up there.
@@ -557,7 +534,7 @@ impl Step for JsonStd {
557
534
const STD_PUBLIC_CRATES : [ & str ; 5 ] = [ "core" , "alloc" , "std" , "proc_macro" , "test" ] ;
558
535
559
536
#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
560
- enum DocumentationFormat {
537
+ pub enum DocumentationFormat {
561
538
HTML ,
562
539
JSON ,
563
540
}
0 commit comments