Skip to content

Fix mdbook test #741

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

Merged
merged 4 commits into from
Jul 25, 2018
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
5 changes: 3 additions & 2 deletions src/book/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,13 @@ impl MDBook {
.flat_map(|x| vec![x.0, x.1])
.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());

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() {
if let BookItem::Chapter(ref ch) = *item {
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// Subcommand modules for the `mdbook` binary.
//! Subcommand modules for the `mdbook` binary.

pub mod build;
pub mod clean;
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ extern crate ws;
use self::iron::{
status, AfterMiddleware, Chain, Iron, IronError, IronResult, Request, Response, Set,
};
#[cfg(feature = "watch")]
use super::watch;
use clap::{App, ArgMatches, SubCommand};
use mdbook::errors::*;
use mdbook::utils;
use mdbook::MDBook;
use std;
#[cfg(feature = "watch")]
use super::watch;
use {get_book_dir, open};

struct ErrorRecover;
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/html_handlebars/hbs_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ impl Renderer for HtmlHandlebars {
.chain_err(|| "Unable to copy across additional CSS and JS")?;

// Render search index
#[cfg(feature = "search")] {
#[cfg(feature = "search")]
{
let search = html_config.search.unwrap_or_default();
if search.enable {
super::search::create_files(&search, &destination, &book)?;
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy_book/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl DummyBook {
/// Write a book to a temporary directory using the provided settings.
pub fn build(&self) -> Result<TempDir> {
let temp = TempFileBuilder::new()
.prefix("dummy_book")
.prefix("dummy_book-")
.tempdir()
.chain_err(|| "Unable to create temp directory")?;

Expand Down
5 changes: 5 additions & 0 deletions tests/dummy_book/src/README.md
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions tests/dummy_book/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Summary

[Dummy Book](README.md)
[Introduction](intro.md)

- [First Chapter](first/index.md)
Expand Down
6 changes: 4 additions & 2 deletions tests/rendered_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const TOC_TOP_LEVEL: &[&'static str] = &[
"1. First Chapter",
"2. Second Chapter",
"Conclusion",
"Dummy Book",
"Introduction",
];
const TOC_SECOND_LEVEL: &[&'static str] =
Expand Down Expand Up @@ -126,7 +127,8 @@ fn rendered_code_has_playpen_stuff() {
#[test]
fn chapter_content_appears_in_rendered_document() {
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"),
("first/nested.html", "testable code"),
("first/index.html", "more text"),
Expand Down Expand Up @@ -437,7 +439,7 @@ mod search {
assert_eq!(docs[&some_section]["body"], "");
assert_eq!(
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[&conclusion]["body"], "I put &lt;HTML&gt; in here!");
Expand Down
Loading