Skip to content

update mdbook #44267

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

Closed
wants to merge 2 commits into from
Closed
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
16 changes: 10 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.23"
default-features = false
19 changes: 5 additions & 14 deletions src/tools/rustbook/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ fn main() {
// Check which subcomamnd the user ran...
let res = match matches.subcommand() {
("build", Some(sub_matches)) => build(sub_matches),
("test", Some(sub_matches)) => test(sub_matches),
(_, _) => unreachable!(),
};

Expand All @@ -53,10 +52,10 @@ fn main() {

// Build command implementation
fn build(args: &ArgMatches) -> Result<(), Box<Error>> {
let book = build_mdbook_struct(args);
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)),
Some(dest_dir) => book.with_destination(Path::new(dest_dir)),
None => book
};

Expand All @@ -65,25 +64,17 @@ fn build(args: &ArgMatches) -> Result<(), Box<Error>> {
Ok(())
}

fn test(args: &ArgMatches) -> Result<(), Box<Error>> {
let mut book = build_mdbook_struct(args);

try!(book.test());

Ok(())
}

fn build_mdbook_struct(args: &ArgMatches) -> mdbook::MDBook {
fn build_mdbook_struct(args: &ArgMatches) -> Result<mdbook::MDBook, Box<Error>> {
let book_dir = get_book_dir(args);
let mut book = MDBook::new(&book_dir).read_config();
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
Ok(book)
}

fn get_book_dir(args: &ArgMatches) -> PathBuf {
Expand Down