@@ -29,7 +29,7 @@ macro_rules! submodule_helper {
2929}
3030
3131macro_rules! book {
32- ( $( $name: ident, $path: expr, $book_name: expr $( , submodule $( = $submodule: literal) ? ) ? ; ) +) => {
32+ ( $( $name: ident, $path: expr, $book_name: expr, $lang : expr $( , submodule $( = $submodule: literal) ? ) ? ; ) +) => {
3333 $(
3434 #[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
3535 pub struct $name {
@@ -61,6 +61,7 @@ macro_rules! book {
6161 name: $book_name. to_owned( ) ,
6262 src: builder. src. join( $path) ,
6363 parent: Some ( self ) ,
64+ languages: $lang. into( ) ,
6465 } )
6566 }
6667 }
@@ -74,15 +75,15 @@ macro_rules! book {
7475// FIXME: Make checking for a submodule automatic somehow (maybe by having a list of all submodules
7576// and checking against it?).
7677book ! (
77- CargoBook , "src/tools/cargo/src/doc" , "cargo" , submodule = "src/tools/cargo" ;
78- ClippyBook , "src/tools/clippy/book" , "clippy" ;
79- EditionGuide , "src/doc/edition-guide" , "edition-guide" , submodule;
80- EmbeddedBook , "src/doc/embedded-book" , "embedded-book" , submodule;
81- Nomicon , "src/doc/nomicon" , "nomicon" , submodule;
82- Reference , "src/doc/reference" , "reference" , submodule;
83- RustByExample , "src/doc/rust-by-example" , "rust-by-example" , submodule;
84- RustdocBook , "src/doc/rustdoc" , "rustdoc" ;
85- StyleGuide , "src/doc/style-guide" , "style-guide" ;
78+ CargoBook , "src/tools/cargo/src/doc" , "cargo" , & [ ] , submodule = "src/tools/cargo" ;
79+ ClippyBook , "src/tools/clippy/book" , "clippy" , & [ ] ;
80+ EditionGuide , "src/doc/edition-guide" , "edition-guide" , & [ ] , submodule;
81+ EmbeddedBook , "src/doc/embedded-book" , "embedded-book" , & [ ] , submodule;
82+ Nomicon , "src/doc/nomicon" , "nomicon" , & [ ] , submodule;
83+ Reference , "src/doc/reference" , "reference" , & [ ] , submodule;
84+ RustByExample , "src/doc/rust-by-example" , "rust-by-example" , & [ "ja" ] , submodule;
85+ RustdocBook , "src/doc/rustdoc" , "rustdoc" , & [ ] ;
86+ StyleGuide , "src/doc/style-guide" , "style-guide" , & [ ] ;
8687) ;
8788
8889#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
@@ -110,6 +111,7 @@ impl Step for UnstableBook {
110111 name : "unstable-book" . to_owned ( ) ,
111112 src : builder. md_doc_out ( self . target ) . join ( "unstable-book" ) ,
112113 parent : Some ( self ) ,
114+ languages : vec ! [ ] ,
113115 } )
114116 }
115117}
@@ -120,6 +122,7 @@ struct RustbookSrc<P: Step> {
120122 name : String ,
121123 src : PathBuf ,
122124 parent : Option < P > ,
125+ languages : Vec < & ' static str > ,
123126}
124127
125128impl < P : Step > Step for RustbookSrc < P > {
@@ -151,7 +154,19 @@ impl<P: Step> Step for RustbookSrc<P> {
151154 builder. info ( & format ! ( "Rustbook ({target}) - {name}" ) ) ;
152155 let _ = fs:: remove_dir_all ( & out) ;
153156
154- builder. run ( rustbook_cmd. arg ( "build" ) . arg ( src) . arg ( "-d" ) . arg ( out) ) ;
157+ builder. run ( rustbook_cmd. arg ( "build" ) . arg ( & src) . arg ( "-d" ) . arg ( & out) ) ;
158+
159+ for lang in & self . languages {
160+ let out = out. join ( lang) ;
161+
162+ builder. info ( & format ! ( "Rustbook ({target}) - {name} - {lang}" ) ) ;
163+ let _ = fs:: remove_dir_all ( & out) ;
164+
165+ let mut rustbook_cmd = builder. tool_cmd ( Tool :: Rustbook ) ;
166+ builder. run (
167+ rustbook_cmd. arg ( "build" ) . arg ( & src) . arg ( "-d" ) . arg ( & out) . arg ( "-l" ) . arg ( lang) ,
168+ ) ;
169+ }
155170 }
156171
157172 if self . parent . is_some ( ) {
@@ -214,6 +229,7 @@ impl Step for TheBook {
214229 name : "book" . to_owned ( ) ,
215230 src : absolute_path. clone ( ) ,
216231 parent : Some ( self ) ,
232+ languages : vec ! [ ] ,
217233 } ) ;
218234
219235 // building older edition redirects
@@ -225,6 +241,7 @@ impl Step for TheBook {
225241 // There should only be one book that is marked as the parent for each target, so
226242 // treat the other editions as not having a parent.
227243 parent : Option :: < Self > :: None ,
244+ languages : vec ! [ ] ,
228245 } ) ;
229246 }
230247
@@ -1200,6 +1217,7 @@ impl Step for RustcBook {
12001217 name : "rustc" . to_owned ( ) ,
12011218 src : out_base,
12021219 parent : Some ( self ) ,
1220+ languages : vec ! [ ] ,
12031221 } ) ;
12041222 }
12051223}
0 commit comments