@@ -102,18 +102,10 @@ fn open(builder: &Builder<'_>, path: impl AsRef<Path>) {
102
102
// Used for deciding whether a particular step is one requested by the user on
103
103
// the `x.py doc` command line, which determines whether `--open` will open that
104
104
// page.
105
- fn components_simplified ( path : & PathBuf ) -> Vec < & str > {
105
+ pub ( crate ) fn components_simplified ( path : & PathBuf ) -> Vec < & str > {
106
106
path. iter ( ) . map ( |component| component. to_str ( ) . unwrap_or ( "???" ) ) . collect ( )
107
107
}
108
108
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
-
117
109
#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
118
110
pub struct UnstableBook {
119
111
target : TargetSelection ,
@@ -248,7 +240,7 @@ impl Step for TheBook {
248
240
invoke_rustdoc ( builder, compiler, target, path) ;
249
241
}
250
242
251
- if is_explicit_request ( builder, "src/doc/book" ) {
243
+ if builder. was_invoked_explicitly :: < Self > ( ) {
252
244
let out = builder. doc_out ( target) ;
253
245
let index = out. join ( "book" ) . join ( "index.html" ) ;
254
246
open ( builder, & index) ;
@@ -408,7 +400,7 @@ impl Step for Standalone {
408
400
409
401
// We open doc/index.html as the default if invoked as `x.py doc --open`
410
402
// 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 > ( ) {
412
404
let index = out. join ( "index.html" ) ;
413
405
open ( builder, & index) ;
414
406
}
@@ -553,7 +545,6 @@ impl Step for Rustc {
553
545
fn run ( self , builder : & Builder < ' _ > ) {
554
546
let stage = self . stage ;
555
547
let target = self . target ;
556
- let mut is_explicit_request = false ;
557
548
builder. info ( & format ! ( "Documenting stage{} compiler ({})" , stage, target) ) ;
558
549
559
550
let paths = builder
@@ -562,15 +553,14 @@ impl Step for Rustc {
562
553
. map ( components_simplified)
563
554
. filter_map ( |path| {
564
555
if path. get ( 0 ) == Some ( & "compiler" ) {
565
- is_explicit_request = true ;
566
556
path. get ( 1 ) . map ( |p| p. to_owned ( ) )
567
557
} else {
568
558
None
569
559
}
570
560
} )
571
561
. collect :: < Vec < _ > > ( ) ;
572
562
573
- if !builder. config . compiler_docs && !is_explicit_request {
563
+ if !builder. config . compiler_docs && !builder . was_invoked_explicitly :: < Self > ( ) {
574
564
builder. info ( "\t skipping - compiler/librustdoc docs disabled" ) ;
575
565
return ;
576
566
}
@@ -700,15 +690,22 @@ macro_rules! tool_doc {
700
690
fn run( self , builder: & Builder <' _>) {
701
691
let stage = self . stage;
702
692
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
+ ) ;
704
701
705
702
// This is the intended out directory for compiler documentation.
706
703
let out = builder. compiler_doc_out( target) ;
707
704
t!( fs:: create_dir_all( & out) ) ;
708
705
709
706
let compiler = builder. compiler( stage, builder. config. build) ;
710
707
711
- if !builder. config. compiler_docs {
708
+ if !builder. config. compiler_docs && !builder . was_invoked_explicitly :: < Self > ( ) {
712
709
builder. info( "\t skipping - compiler/tool docs disabled" ) ;
713
710
return ;
714
711
}
@@ -912,7 +909,7 @@ impl Step for RustcBook {
912
909
name : INTERNER . intern_str ( "rustc" ) ,
913
910
src : INTERNER . intern_path ( out_base) ,
914
911
} ) ;
915
- if is_explicit_request ( builder, "src/doc/rustc" ) {
912
+ if builder. was_invoked_explicitly :: < Self > ( ) {
916
913
let out = builder. doc_out ( self . target ) ;
917
914
let index = out. join ( "rustc" ) . join ( "index.html" ) ;
918
915
open ( builder, & index) ;
0 commit comments