@@ -18,19 +18,10 @@ use crate::core::builder::{
18
18
self , Alias , Builder , Compiler , Kind , RunConfig , ShouldRun , Step , crate_description,
19
19
} ;
20
20
use 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} ;
31
22
32
23
macro_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 ; ) +) => {
34
25
$(
35
26
#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
36
27
pub struct $name {
@@ -53,10 +44,10 @@ macro_rules! book {
53
44
}
54
45
55
46
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
+
60
51
builder. ensure( RustbookSrc {
61
52
target: self . target,
62
53
name: $book_name. to_owned( ) ,
@@ -77,12 +68,12 @@ macro_rules! book {
77
68
// FIXME: Make checking for a submodule automatic somehow (maybe by having a list of all submodules
78
69
// and checking against it?).
79
70
book ! (
80
- CargoBook , "src/tools/cargo/src/doc" , "cargo" , & [ ] , submodule = "src/tools/cargo" ;
71
+ CargoBook , "src/tools/cargo/src/doc" , "cargo" , & [ ] ;
81
72
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" ] ;
86
77
RustdocBook , "src/doc/rustdoc" , "rustdoc" , & [ ] ;
87
78
StyleGuide , "src/doc/style-guide" , "style-guide" , & [ ] ;
88
79
) ;
@@ -910,7 +901,6 @@ macro_rules! tool_doc {
910
901
$( rustc_tool = $rustc_tool: literal, ) ?
911
902
$( is_library = $is_library: expr, ) ?
912
903
$( crates = $crates: expr) ?
913
- $( , submodule $( = $submodule: literal) ? ) ?
914
904
) => {
915
905
#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
916
906
pub struct $tool {
@@ -938,14 +928,12 @@ macro_rules! tool_doc {
938
928
/// we do not merge it with the other documentation from std, test and
939
929
/// proc_macros. This is largely just a wrapper around `cargo doc`.
940
930
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 ;
945
932
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
+ }
949
937
950
938
let stage = builder. top_stage;
951
939
let target = self . target;
@@ -1054,8 +1042,7 @@ tool_doc!(
1054
1042
"crates-io" ,
1055
1043
"mdman" ,
1056
1044
"rustfix" ,
1057
- ] ,
1058
- submodule = "src/tools/cargo"
1045
+ ]
1059
1046
) ;
1060
1047
tool_doc ! ( Tidy , "src/tools/tidy" , rustc_tool = false , crates = [ "tidy" ] ) ;
1061
1048
tool_doc ! (
0 commit comments