commit
b4e15e5357
|
@ -213,12 +213,13 @@ impl MDBook {
|
||||||
.flat_map(|x| vec![x.0, x.1])
|
.flat_map(|x| vec![x.0, x.1])
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let temp_dir = TempFileBuilder::new().prefix("mdbook").tempdir()?;
|
let temp_dir = TempFileBuilder::new().prefix("mdbook-").tempdir()?;
|
||||||
|
|
||||||
let preprocess_context = PreprocessorContext::new(self.root.clone(), self.config.clone());
|
let preprocess_context = PreprocessorContext::new(self.root.clone(), self.config.clone());
|
||||||
|
|
||||||
LinkPreprocessor::new().run(&preprocess_context, &mut self.book)?;
|
LinkPreprocessor::new().run(&preprocess_context, &mut self.book)?;
|
||||||
IndexPreprocessor::new().run(&preprocess_context, &mut self.book)?;
|
// Index Preprocessor is disabled so that chapter paths continue to point to the
|
||||||
|
// actual markdown files.
|
||||||
|
|
||||||
for item in self.iter() {
|
for item in self.iter() {
|
||||||
if let BookItem::Chapter(ref ch) = *item {
|
if let BookItem::Chapter(ref ch) = *item {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/// Subcommand modules for the `mdbook` binary.
|
//! Subcommand modules for the `mdbook` binary.
|
||||||
|
|
||||||
pub mod build;
|
pub mod build;
|
||||||
pub mod clean;
|
pub mod clean;
|
||||||
|
|
|
@ -5,13 +5,13 @@ extern crate ws;
|
||||||
use self::iron::{
|
use self::iron::{
|
||||||
status, AfterMiddleware, Chain, Iron, IronError, IronResult, Request, Response, Set,
|
status, AfterMiddleware, Chain, Iron, IronError, IronResult, Request, Response, Set,
|
||||||
};
|
};
|
||||||
|
#[cfg(feature = "watch")]
|
||||||
|
use super::watch;
|
||||||
use clap::{App, ArgMatches, SubCommand};
|
use clap::{App, ArgMatches, SubCommand};
|
||||||
use mdbook::errors::*;
|
use mdbook::errors::*;
|
||||||
use mdbook::utils;
|
use mdbook::utils;
|
||||||
use mdbook::MDBook;
|
use mdbook::MDBook;
|
||||||
use std;
|
use std;
|
||||||
#[cfg(feature = "watch")]
|
|
||||||
use super::watch;
|
|
||||||
use {get_book_dir, open};
|
use {get_book_dir, open};
|
||||||
|
|
||||||
struct ErrorRecover;
|
struct ErrorRecover;
|
||||||
|
|
|
@ -370,7 +370,8 @@ impl Renderer for HtmlHandlebars {
|
||||||
.chain_err(|| "Unable to copy across additional CSS and JS")?;
|
.chain_err(|| "Unable to copy across additional CSS and JS")?;
|
||||||
|
|
||||||
// Render search index
|
// Render search index
|
||||||
#[cfg(feature = "search")] {
|
#[cfg(feature = "search")]
|
||||||
|
{
|
||||||
let search = html_config.search.unwrap_or_default();
|
let search = html_config.search.unwrap_or_default();
|
||||||
if search.enable {
|
if search.enable {
|
||||||
super::search::create_files(&search, &destination, &book)?;
|
super::search::create_files(&search, &destination, &book)?;
|
||||||
|
|
|
@ -47,7 +47,7 @@ impl DummyBook {
|
||||||
/// Write a book to a temporary directory using the provided settings.
|
/// Write a book to a temporary directory using the provided settings.
|
||||||
pub fn build(&self) -> Result<TempDir> {
|
pub fn build(&self) -> Result<TempDir> {
|
||||||
let temp = TempFileBuilder::new()
|
let temp = TempFileBuilder::new()
|
||||||
.prefix("dummy_book")
|
.prefix("dummy_book-")
|
||||||
.tempdir()
|
.tempdir()
|
||||||
.chain_err(|| "Unable to create temp directory")?;
|
.chain_err(|| "Unable to create temp directory")?;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Dummy Book
|
||||||
|
|
||||||
|
This file is just here to cause the index preprocessor to run.
|
||||||
|
|
||||||
|
Does a pretty good job, too.
|
|
@ -1,5 +1,6 @@
|
||||||
# Summary
|
# Summary
|
||||||
|
|
||||||
|
[Dummy Book](README.md)
|
||||||
[Introduction](intro.md)
|
[Introduction](intro.md)
|
||||||
|
|
||||||
- [First Chapter](first/index.md)
|
- [First Chapter](first/index.md)
|
||||||
|
|
|
@ -27,6 +27,7 @@ const TOC_TOP_LEVEL: &[&'static str] = &[
|
||||||
"1. First Chapter",
|
"1. First Chapter",
|
||||||
"2. Second Chapter",
|
"2. Second Chapter",
|
||||||
"Conclusion",
|
"Conclusion",
|
||||||
|
"Dummy Book",
|
||||||
"Introduction",
|
"Introduction",
|
||||||
];
|
];
|
||||||
const TOC_SECOND_LEVEL: &[&'static str] =
|
const TOC_SECOND_LEVEL: &[&'static str] =
|
||||||
|
@ -126,7 +127,8 @@ fn rendered_code_has_playpen_stuff() {
|
||||||
#[test]
|
#[test]
|
||||||
fn chapter_content_appears_in_rendered_document() {
|
fn chapter_content_appears_in_rendered_document() {
|
||||||
let content = vec![
|
let content = vec![
|
||||||
("index.html", "Here's some interesting text"),
|
("index.html", "This file is just here to cause the"),
|
||||||
|
("intro.html", "Here's some interesting text"),
|
||||||
("second.html", "Second Chapter"),
|
("second.html", "Second Chapter"),
|
||||||
("first/nested.html", "testable code"),
|
("first/nested.html", "testable code"),
|
||||||
("first/index.html", "more text"),
|
("first/index.html", "more text"),
|
||||||
|
@ -437,7 +439,7 @@ mod search {
|
||||||
assert_eq!(docs[&some_section]["body"], "");
|
assert_eq!(docs[&some_section]["body"], "");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
docs[&summary]["body"],
|
docs[&summary]["body"],
|
||||||
"Introduction First Chapter Nested Chapter Includes Recursive Second Chapter Conclusion"
|
"Dummy Book Introduction First Chapter Nested Chapter Includes Recursive Second Chapter Conclusion"
|
||||||
);
|
);
|
||||||
assert_eq!(docs[&summary]["breadcrumbs"], "First Chapter » Summary");
|
assert_eq!(docs[&summary]["breadcrumbs"], "First Chapter » Summary");
|
||||||
assert_eq!(docs[&conclusion]["body"], "I put <HTML> in here!");
|
assert_eq!(docs[&conclusion]["body"], "I put <HTML> in here!");
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -23,7 +23,7 @@ fn mdbook_can_correctly_test_a_passing_book() {
|
||||||
#[test]
|
#[test]
|
||||||
fn mdbook_detects_book_with_failing_tests() {
|
fn mdbook_detects_book_with_failing_tests() {
|
||||||
let temp = DummyBook::new().with_passing_test(false).build().unwrap();
|
let temp = DummyBook::new().with_passing_test(false).build().unwrap();
|
||||||
let mut md: MDBook = MDBook::load(temp.path()).unwrap();
|
let mut md = MDBook::load(temp.path()).unwrap();
|
||||||
|
|
||||||
assert!(md.test(vec![]).is_err());
|
assert!(md.test(vec![]).is_err());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue