@@ -18,19 +18,10 @@ use crate::core::builder::{
1818 self , Alias , Builder , Compiler , Kind , RunConfig , ShouldRun , Step , crate_description,
1919} ;
2020use crate :: core:: config:: { Config , TargetSelection } ;
21- use crate :: utils:: helpers:: { symlink_dir, t, up_to_date} ;
22-
23- macro_rules! submodule_helper {
24- ( $path: expr, submodule) => {
25- $path
26- } ;
27- ( $path: expr, submodule = $submodule: literal) => {
28- $submodule
29- } ;
30- }
21+ use crate :: helpers:: { is_path_in_submodule, symlink_dir, t, up_to_date} ;
3122
3223macro_rules! book {
33- ( $( $name: ident, $path: expr, $book_name: expr, $lang: expr $ ( , submodule $ ( = $submodule : literal ) ? ) ? ; ) +) => {
24+ ( $( $name: ident, $path: expr, $book_name: expr, $lang: expr ; ) +) => {
3425 $(
3526 #[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
3627 pub struct $name {
@@ -53,10 +44,10 @@ macro_rules! book {
5344 }
5445
5546 fn run( self , builder: & Builder <' _>) {
56- $ (
57- let path = submodule_helper! ( $path, submodule $ ( = $submodule ) ? ) ;
58- builder . require_submodule ( path , None ) ;
59- ) ?
47+ if is_path_in_submodule ( & builder , $path ) {
48+ builder . require_submodule ( $path, None ) ;
49+ }
50+
6051 builder. ensure( RustbookSrc {
6152 target: self . target,
6253 name: $book_name. to_owned( ) ,
@@ -77,12 +68,12 @@ macro_rules! book {
7768// FIXME: Make checking for a submodule automatic somehow (maybe by having a list of all submodules
7869// and checking against it?).
7970book ! (
80- CargoBook , "src/tools/cargo/src/doc" , "cargo" , & [ ] , submodule = "src/tools/cargo" ;
71+ CargoBook , "src/tools/cargo/src/doc" , "cargo" , & [ ] ;
8172 ClippyBook , "src/tools/clippy/book" , "clippy" , & [ ] ;
82- EditionGuide , "src/doc/edition-guide" , "edition-guide" , & [ ] , submodule ;
83- EmbeddedBook , "src/doc/embedded-book" , "embedded-book" , & [ ] , submodule ;
84- Nomicon , "src/doc/nomicon" , "nomicon" , & [ ] , submodule ;
85- RustByExample , "src/doc/rust-by-example" , "rust-by-example" , & [ "ja" , "zh" ] , submodule ;
73+ EditionGuide , "src/doc/edition-guide" , "edition-guide" , & [ ] ;
74+ EmbeddedBook , "src/doc/embedded-book" , "embedded-book" , & [ ] ;
75+ Nomicon , "src/doc/nomicon" , "nomicon" , & [ ] ;
76+ RustByExample , "src/doc/rust-by-example" , "rust-by-example" , & [ "ja" , "zh" ] ;
8677 RustdocBook , "src/doc/rustdoc" , "rustdoc" , & [ ] ;
8778 StyleGuide , "src/doc/style-guide" , "style-guide" , & [ ] ;
8879) ;
@@ -910,7 +901,6 @@ macro_rules! tool_doc {
910901 $( rustc_tool = $rustc_tool: literal, ) ?
911902 $( is_library = $is_library: expr, ) ?
912903 $( crates = $crates: expr) ?
913- $( , submodule $( = $submodule: literal) ? ) ?
914904 ) => {
915905 #[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
916906 pub struct $tool {
@@ -938,14 +928,12 @@ macro_rules! tool_doc {
938928 /// we do not merge it with the other documentation from std, test and
939929 /// proc_macros. This is largely just a wrapper around `cargo doc`.
940930 fn run( self , builder: & Builder <' _>) {
941- let source_type = SourceType :: InTree ;
942- $(
943- let _ = source_type; // silence the "unused variable" warning
944- let source_type = SourceType :: Submodule ;
931+ let mut source_type = SourceType :: InTree ;
945932
946- let path = submodule_helper!( $path, submodule $( = $submodule ) ? ) ;
947- builder. require_submodule( path, None ) ;
948- ) ?
933+ if is_path_in_submodule( & builder, $path) {
934+ source_type = SourceType :: Submodule ;
935+ builder. require_submodule( $path, None ) ;
936+ }
949937
950938 let stage = builder. top_stage;
951939 let target = self . target;
@@ -1054,8 +1042,7 @@ tool_doc!(
10541042 "crates-io" ,
10551043 "mdman" ,
10561044 "rustfix" ,
1057- ] ,
1058- submodule = "src/tools/cargo"
1045+ ]
10591046) ;
10601047tool_doc ! ( Tidy , "src/tools/tidy" , rustc_tool = false , crates = [ "tidy" ] ) ;
10611048tool_doc ! (
0 commit comments