diff options
| author | steveklabnik <steve@steveklabnik.com> | 2017-09-11 11:55:07 -0400 |
|---|---|---|
| committer | steveklabnik <steve@steveklabnik.com> | 2017-09-11 11:56:35 -0400 |
| commit | f3d6f120e8e9ef3ffa714bcf4dbba541b1443af4 (patch) | |
| tree | 92963b99c9ae3e1557f8e1b2aa94921b2104128e /src/tools/rustbook | |
| parent | 19d30fcdb28c2a4f57774b827b1a17ee156b5c56 (diff) | |
update mdbook
Diffstat (limited to 'src/tools/rustbook')
| -rw-r--r-- | src/tools/rustbook/Cargo.toml | 2 | ||||
| -rw-r--r-- | src/tools/rustbook/src/main.rs | 27 |
2 files changed, 8 insertions, 21 deletions
diff --git a/src/tools/rustbook/Cargo.toml b/src/tools/rustbook/Cargo.toml index e759e0bc13a..e57c105008a 100644 --- a/src/tools/rustbook/Cargo.toml +++ b/src/tools/rustbook/Cargo.toml @@ -8,5 +8,5 @@ license = "MIT/Apache-2.0" clap = "2.25.0" [dependencies.mdbook] -version = "0.0.22" +version = "0.0.25" default-features = false diff --git a/src/tools/rustbook/src/main.rs b/src/tools/rustbook/src/main.rs index 41e88aa245f..a0c3e811a7a 100644 --- a/src/tools/rustbook/src/main.rs +++ b/src/tools/rustbook/src/main.rs @@ -13,13 +13,13 @@ extern crate mdbook; extern crate clap; use std::env; -use std::error::Error; use std::io::{self, Write}; use std::path::{Path, PathBuf}; use clap::{App, ArgMatches, SubCommand, AppSettings}; use mdbook::MDBook; +use mdbook::errors::Result; fn main() { let d_message = "-d, --dest-dir=[dest-dir] @@ -49,34 +49,21 @@ fn main() { ::std::process::exit(101); } } - // Build command implementation -fn build(args: &ArgMatches) -> Result<(), Box<Error>> { - let book = build_mdbook_struct(args); +pub fn build(args: &ArgMatches) -> Result<()> { + let book_dir = get_book_dir(args); + let book = MDBook::new(&book_dir).read_config()?; let mut book = match args.value_of("dest-dir") { - Some(dest_dir) => book.set_dest(Path::new(dest_dir)), - None => book + Some(dest_dir) => book.with_destination(dest_dir), + None => book, }; - try!(book.build()); + book.build()?; Ok(()) } -fn build_mdbook_struct(args: &ArgMatches) -> mdbook::MDBook { - let book_dir = get_book_dir(args); - let mut book = MDBook::new(&book_dir).read_config(); - - // By default mdbook will attempt to create non-existent files referenced - // from SUMMARY.md files. This is problematic on CI where we mount the - // source directory as readonly. To avoid any issues, we'll disabled - // mdbook's implicit file creation feature. - book.create_missing = false; - - book -} - fn get_book_dir(args: &ArgMatches) -> PathBuf { if let Some(dir) = args.value_of("dir") { // Check if path is relative from current dir, or absolute... |
