@@ -13,13 +13,13 @@ extern crate mdbook;
13
13
extern crate clap;
14
14
15
15
use std:: env;
16
- use std:: error:: Error ;
17
16
use std:: io:: { self , Write } ;
18
17
use std:: path:: { Path , PathBuf } ;
19
18
20
19
use clap:: { App , ArgMatches , SubCommand , AppSettings } ;
21
20
22
21
use mdbook:: MDBook ;
22
+ use mdbook:: errors:: Result ;
23
23
24
24
fn main ( ) {
25
25
let d_message = "-d, --dest-dir=[dest-dir]
@@ -49,34 +49,21 @@ fn main() {
49
49
:: std:: process:: exit ( 101 ) ;
50
50
}
51
51
}
52
-
53
52
// Build command implementation
54
- fn build ( args : & ArgMatches ) -> Result < ( ) , Box < Error > > {
55
- let book = build_mdbook_struct ( args) ;
53
+ pub fn build ( args : & ArgMatches ) -> Result < ( ) > {
54
+ let book_dir = get_book_dir ( args) ;
55
+ let book = MDBook :: new ( & book_dir) . read_config ( ) ?;
56
56
57
57
let mut book = match args. value_of ( "dest-dir" ) {
58
- Some ( dest_dir) => book. set_dest ( Path :: new ( dest_dir) ) ,
59
- None => book
58
+ Some ( dest_dir) => book. with_destination ( dest_dir) ,
59
+ None => book,
60
60
} ;
61
61
62
- try! ( book. build ( ) ) ;
62
+ book. build ( ) ? ;
63
63
64
64
Ok ( ( ) )
65
65
}
66
66
67
- fn build_mdbook_struct ( args : & ArgMatches ) -> mdbook:: MDBook {
68
- let book_dir = get_book_dir ( args) ;
69
- let mut book = MDBook :: new ( & book_dir) . read_config ( ) ;
70
-
71
- // By default mdbook will attempt to create non-existent files referenced
72
- // from SUMMARY.md files. This is problematic on CI where we mount the
73
- // source directory as readonly. To avoid any issues, we'll disabled
74
- // mdbook's implicit file creation feature.
75
- book. create_missing = false ;
76
-
77
- book
78
- }
79
-
80
67
fn get_book_dir ( args : & ArgMatches ) -> PathBuf {
81
68
if let Some ( dir) = args. value_of ( "dir" ) {
82
69
// Check if path is relative from current dir, or absolute...
0 commit comments