@@ -53,9 +53,58 @@ pub fn rustbook(build: &Build, target: &str, name: &str) {
53
53
. arg ( out) ) ;
54
54
}
55
55
56
+ /// Build the book and associated stuff.
57
+ ///
58
+ /// We need to build:
59
+ ///
60
+ /// * Book (first edition)
61
+ /// * Book (second edition)
62
+ /// * Index page
63
+ /// * Redirect pages
56
64
pub fn book ( build : & Build , target : & str , name : & str ) {
65
+ // build book first edition
57
66
rustbook ( build, target, & format ! ( "{}/first-edition" , name) ) ;
67
+
68
+ // build book second edition
58
69
rustbook ( build, target, & format ! ( "{}/second-edition" , name) ) ;
70
+
71
+ // build the index page
72
+ let index = format ! ( "{}/index.md" , name) ;
73
+ invoke_rustdoc ( build, target, & index) ;
74
+ }
75
+
76
+ fn invoke_rustdoc ( build : & Build , target : & str , markdown : & str ) {
77
+ let out = build. doc_out ( target) ;
78
+
79
+ let compiler = Compiler :: new ( 0 , & build. config . build ) ;
80
+
81
+ let path = build. src . join ( "src/doc" ) . join ( markdown) ;
82
+
83
+ let rustdoc = build. rustdoc ( & compiler) ;
84
+
85
+ let favicon = build. src . join ( "src/doc/favicon.inc" ) ;
86
+ let footer = build. src . join ( "src/doc/footer.inc" ) ;
87
+ t ! ( fs:: copy( build. src. join( "src/doc/rust.css" ) , out. join( "rust.css" ) ) ) ;
88
+
89
+ let version_info = out. join ( "version_info.html" ) ;
90
+
91
+ let mut cmd = Command :: new ( & rustdoc) ;
92
+
93
+ build. add_rustc_lib_path ( & compiler, & mut cmd) ;
94
+
95
+ let out = out. join ( "book" ) ;
96
+
97
+ cmd. arg ( "--html-after-content" ) . arg ( & footer)
98
+ . arg ( "--html-before-content" ) . arg ( & version_info)
99
+ . arg ( "--html-in-header" ) . arg ( & favicon)
100
+ . arg ( "--markdown-playground-url" )
101
+ . arg ( "https://play.rust-lang.org/" )
102
+ . arg ( "-o" ) . arg ( & out)
103
+ . arg ( & path)
104
+ . arg ( "--markdown-css" )
105
+ . arg ( "rust.css" ) ;
106
+
107
+ build. run ( & mut cmd) ;
59
108
}
60
109
61
110
/// Generates all standalone documentation as compiled by the rustdoc in `stage`
0 commit comments