Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump mdbook dep to pick up new 'create missing' toggle feature. #41572

Merged
merged 1 commit into from
Apr 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/tools/rustbook/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ license = "MIT/Apache-2.0"
clap = "2.19.3"

[dependencies.mdbook]
version = "0.0.19"
version = "0.0.21"
default-features = false
19 changes: 15 additions & 4 deletions src/tools/rustbook/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ fn main() {

// Build command implementation
fn build(args: &ArgMatches) -> Result<(), Box<Error>> {
let book_dir = get_book_dir(args);
let book = MDBook::new(&book_dir).read_config();
let book = build_mdbook_struct(args);

let mut book = match args.value_of("dest-dir") {
Some(dest_dir) => book.set_dest(Path::new(dest_dir)),
Expand All @@ -67,14 +66,26 @@ fn build(args: &ArgMatches) -> Result<(), Box<Error>> {
}

fn test(args: &ArgMatches) -> Result<(), Box<Error>> {
let book_dir = get_book_dir(args);
let mut book = MDBook::new(&book_dir).read_config();
let mut book = build_mdbook_struct(args);

try!(book.test());

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...
Expand Down