Skip to content

Commit

Permalink
Rollup merge of rust-lang#44430 - steveklabnik:update-mdbook, r=alexc…
Browse files Browse the repository at this point in the history
…richton

update mdbook

This eliminates some warnings

r? @alexcrichton
  • Loading branch information
frewsxcv authored Sep 15, 2017
2 parents eb45c0a + f3d6f12 commit 5255ab7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
25 changes: 19 additions & 6 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.25.0"

[dependencies.mdbook]
version = "0.0.22"
version = "0.0.25"
default-features = false
27 changes: 7 additions & 20 deletions src/tools/rustbook/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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...
Expand Down

0 comments on commit 5255ab7

Please sign in to comment.