@@ -434,6 +434,7 @@ impl Step for SharedAssets {
434434pub struct Std {
435435 pub stage : u32 ,
436436 pub target : TargetSelection ,
437+ pub format : DocumentationFormat ,
437438}
438439
439440impl Step for Std {
@@ -446,7 +447,15 @@ impl Step for Std {
446447 }
447448
448449 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+ } ) ;
450459 }
451460
452461 /// Compile all standard library documentation.
@@ -462,13 +471,16 @@ impl Step for Std {
462471 builder. ensure ( SharedAssets { target : self . target } ) ;
463472
464473 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+ } ;
472484
473485 if !builder. config . docs_minification {
474486 extra_args. push ( OsStr :: new ( "--disable-minification" ) ) ;
@@ -492,15 +504,7 @@ impl Step for Std {
492504 } )
493505 . collect :: < Vec < _ > > ( ) ;
494506
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) ;
504508
505509 // Look for library/std, library/core etc in the `x.py doc` arguments and
506510 // open the corresponding rendered docs.
@@ -513,43 +517,6 @@ impl Step for Std {
513517 }
514518}
515519
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-
553520/// Name of the crates that are visible to consumers of the standard library.
554521/// Documentation for internal crates is handled by the rustc step, so internal crates will show
555522/// up there.
@@ -562,7 +529,7 @@ impl Step for JsonStd {
562529const STD_PUBLIC_CRATES : [ & str ; 5 ] = [ "core" , "alloc" , "std" , "proc_macro" , "test" ] ;
563530
564531#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
565- enum DocumentationFormat {
532+ pub enum DocumentationFormat {
566533 HTML ,
567534 JSON ,
568535}
0 commit comments