@@ -102,18 +102,10 @@ fn open(builder: &Builder<'_>, path: impl AsRef<Path>) {
102102// Used for deciding whether a particular step is one requested by the user on
103103// the `x.py doc` command line, which determines whether `--open` will open that
104104// page.
105- fn components_simplified ( path : & PathBuf ) -> Vec < & str > {
105+ pub ( crate ) fn components_simplified ( path : & PathBuf ) -> Vec < & str > {
106106 path. iter ( ) . map ( |component| component. to_str ( ) . unwrap_or ( "???" ) ) . collect ( )
107107}
108108
109- fn is_explicit_request ( builder : & Builder < ' _ > , path : & str ) -> bool {
110- builder
111- . paths
112- . iter ( )
113- . map ( components_simplified)
114- . any ( |requested| requested. iter ( ) . copied ( ) . eq ( path. split ( '/' ) ) )
115- }
116-
117109#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
118110pub struct UnstableBook {
119111 target : TargetSelection ,
@@ -248,7 +240,7 @@ impl Step for TheBook {
248240 invoke_rustdoc ( builder, compiler, target, path) ;
249241 }
250242
251- if is_explicit_request ( builder, "src/doc/book" ) {
243+ if builder. was_invoked_explicitly :: < Self > ( ) {
252244 let out = builder. doc_out ( target) ;
253245 let index = out. join ( "book" ) . join ( "index.html" ) ;
254246 open ( builder, & index) ;
@@ -408,7 +400,7 @@ impl Step for Standalone {
408400
409401 // We open doc/index.html as the default if invoked as `x.py doc --open`
410402 // with no particular explicit doc requested (e.g. library/core).
411- if builder. paths . is_empty ( ) || is_explicit_request ( builder, "src/doc" ) {
403+ if builder. paths . is_empty ( ) || builder. was_invoked_explicitly :: < Self > ( ) {
412404 let index = out. join ( "index.html" ) ;
413405 open ( builder, & index) ;
414406 }
@@ -553,7 +545,6 @@ impl Step for Rustc {
553545 fn run ( self , builder : & Builder < ' _ > ) {
554546 let stage = self . stage ;
555547 let target = self . target ;
556- let mut is_explicit_request = false ;
557548 builder. info ( & format ! ( "Documenting stage{} compiler ({})" , stage, target) ) ;
558549
559550 let paths = builder
@@ -562,15 +553,14 @@ impl Step for Rustc {
562553 . map ( components_simplified)
563554 . filter_map ( |path| {
564555 if path. get ( 0 ) == Some ( & "compiler" ) {
565- is_explicit_request = true ;
566556 path. get ( 1 ) . map ( |p| p. to_owned ( ) )
567557 } else {
568558 None
569559 }
570560 } )
571561 . collect :: < Vec < _ > > ( ) ;
572562
573- if !builder. config . compiler_docs && !is_explicit_request {
563+ if !builder. config . compiler_docs && !builder . was_invoked_explicitly :: < Self > ( ) {
574564 builder. info ( "\t skipping - compiler/librustdoc docs disabled" ) ;
575565 return ;
576566 }
@@ -700,15 +690,22 @@ macro_rules! tool_doc {
700690 fn run( self , builder: & Builder <' _>) {
701691 let stage = self . stage;
702692 let target = self . target;
703- builder. info( & format!( "Documenting stage{} {} ({})" , stage, stringify!( $tool) . to_lowercase( ) , target) ) ;
693+ builder. info(
694+ & format!(
695+ "Documenting stage{} {} ({})" ,
696+ stage,
697+ stringify!( $tool) . to_lowercase( ) ,
698+ target,
699+ ) ,
700+ ) ;
704701
705702 // This is the intended out directory for compiler documentation.
706703 let out = builder. compiler_doc_out( target) ;
707704 t!( fs:: create_dir_all( & out) ) ;
708705
709706 let compiler = builder. compiler( stage, builder. config. build) ;
710707
711- if !builder. config. compiler_docs {
708+ if !builder. config. compiler_docs && !builder . was_invoked_explicitly :: < Self > ( ) {
712709 builder. info( "\t skipping - compiler/tool docs disabled" ) ;
713710 return ;
714711 }
@@ -912,7 +909,7 @@ impl Step for RustcBook {
912909 name : INTERNER . intern_str ( "rustc" ) ,
913910 src : INTERNER . intern_path ( out_base) ,
914911 } ) ;
915- if is_explicit_request ( builder, "src/doc/rustc" ) {
912+ if builder. was_invoked_explicitly :: < Self > ( ) {
916913 let out = builder. doc_out ( self . target ) ;
917914 let index = out. join ( "rustc" ) . join ( "index.html" ) ;
918915 open ( builder, & index) ;
0 commit comments