All tests finally pass!
This commit is contained in:
parent
21498631b3
commit
f993677626
|
@ -61,11 +61,11 @@ impl MDBook {
|
|||
/// # use mdbook::book::BookItem;
|
||||
/// # #[allow(unused_variables)]
|
||||
/// # fn main() {
|
||||
/// # let book = MDBook::new("mybook");
|
||||
/// # let book = MDBook::load("mybook").unwrap();
|
||||
/// for item in book.iter() {
|
||||
/// match *item {
|
||||
/// BookItem::Chapter(ref chapter) => {},
|
||||
/// BookItem::Spacer => {},
|
||||
/// BookItem::Separator => {},
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
|
@ -140,32 +140,11 @@ impl MDBook {
|
|||
Ok(self)
|
||||
}
|
||||
|
||||
/// You can change the default renderer to another one
|
||||
/// by using this method. The only requirement
|
||||
/// is for your renderer to implement the
|
||||
/// [Renderer trait](../../renderer/renderer/trait.Renderer.html)
|
||||
///
|
||||
/// ```no_run
|
||||
/// extern crate mdbook;
|
||||
/// use mdbook::MDBook;
|
||||
/// use mdbook::renderer::HtmlHandlebars;
|
||||
///
|
||||
/// # #[allow(unused_variables)]
|
||||
/// fn main() {
|
||||
/// let book = MDBook::new("mybook")
|
||||
/// .set_renderer(Box::new(HtmlHandlebars::new()));
|
||||
///
|
||||
/// // In this example we replace the default renderer
|
||||
/// // by the default renderer...
|
||||
/// // Don't forget to put your renderer in a Box
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// **note:** Don't forget to put your renderer in a `Box`
|
||||
/// before passing it to `set_renderer()`
|
||||
|
||||
pub fn set_renderer(mut self, renderer: Box<Renderer>) -> Self {
|
||||
self.renderer = renderer;
|
||||
/// You can change the default renderer to another one by using this method.
|
||||
/// The only requirement is for your renderer to implement the [Renderer
|
||||
/// trait](../../renderer/renderer/trait.Renderer.html)
|
||||
pub fn set_renderer<R: Renderer + 'static>(mut self, renderer: R) -> Self {
|
||||
self.renderer = Box::new(renderer);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
//! use std::path::PathBuf;
|
||||
//!
|
||||
//! fn main() {
|
||||
//! let mut md = MDBook::new("my-book");
|
||||
//! let mut md = MDBook::load("my-book").unwrap();
|
||||
//!
|
||||
//! // tweak the book configuration a bit
|
||||
//! md.config.book.src = PathBuf::from("source");
|
||||
|
@ -52,7 +52,8 @@
|
|||
//! # fn main() {
|
||||
//! # let your_renderer = HtmlHandlebars::new();
|
||||
//! #
|
||||
//! let book = MDBook::new("my-book").set_renderer(Box::new(your_renderer));
|
||||
//! let mut book = MDBook::load("my-book").unwrap();
|
||||
//! book.set_renderer(your_renderer);
|
||||
//! # }
|
||||
//! ```
|
||||
//! If you make a renderer, you get the book constructed in form of `Vec<BookItems>` and you get
|
||||
|
|
|
@ -9,7 +9,7 @@ use theme::{Theme, playpen_editor};
|
|||
use errors::*;
|
||||
use regex::{Captures, Regex};
|
||||
|
||||
use std::ascii::AsciiExt;
|
||||
#[allow(unused_imports)] use std::ascii::AsciiExt;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::fs::{self, File};
|
||||
use std::io::{self, Read};
|
||||
|
|
|
@ -6,4 +6,6 @@
|
|||
- [Nested Chapter](./first/nested.md)
|
||||
- [Second Chapter](./second.md)
|
||||
|
||||
---
|
||||
|
||||
[Conclusion](./conclusion.md)
|
||||
|
|
|
@ -46,7 +46,7 @@ fn run_mdbook_init_with_custom_book_and_src_locations() {
|
|||
cfg.book.src = PathBuf::from("in");
|
||||
cfg.build.build_dir = PathBuf::from("out");
|
||||
|
||||
let mut md = MDBook::init(temp.path()).with_config(cfg).build().unwrap();
|
||||
MDBook::init(temp.path()).with_config(cfg).build().unwrap();
|
||||
|
||||
for file in &created_files {
|
||||
let target = temp.path().join(file);
|
||||
|
|
|
@ -61,10 +61,10 @@ fn make_sure_bottom_level_files_contain_links_to_chapters() {
|
|||
let dest = temp.path().join("book");
|
||||
let links = vec![
|
||||
r#"href="intro.html""#,
|
||||
r#"href="./first/index.html""#,
|
||||
r#"href="./first/nested.html""#,
|
||||
r#"href="./second.html""#,
|
||||
r#"href="./conclusion.html""#,
|
||||
r#"href="first/index.html""#,
|
||||
r#"href="first/nested.html""#,
|
||||
r#"href="second.html""#,
|
||||
r#"href="conclusion.html""#,
|
||||
];
|
||||
|
||||
let files_in_bottom_dir = vec!["index.html", "intro.html", "second.html", "conclusion.html"];
|
||||
|
@ -84,10 +84,10 @@ fn check_correct_cross_links_in_nested_dir() {
|
|||
let links = vec![
|
||||
r#"<base href="../">"#,
|
||||
r#"href="intro.html""#,
|
||||
r#"href="./first/index.html""#,
|
||||
r#"href="./first/nested.html""#,
|
||||
r#"href="./second.html""#,
|
||||
r#"href="./conclusion.html""#,
|
||||
r#"href="first/index.html""#,
|
||||
r#"href="first/nested.html""#,
|
||||
r#"href="second.html""#,
|
||||
r#"href="conclusion.html""#,
|
||||
];
|
||||
|
||||
let files_in_nested_dir = vec!["index.html", "nested.html"];
|
||||
|
@ -99,14 +99,14 @@ fn check_correct_cross_links_in_nested_dir() {
|
|||
assert_contains_strings(
|
||||
first.join("index.html"),
|
||||
&[
|
||||
r##"href="./first/index.html#some-section" id="some-section""##,
|
||||
r##"href="first/index.html#some-section" id="some-section""##,
|
||||
],
|
||||
);
|
||||
|
||||
assert_contains_strings(
|
||||
first.join("nested.html"),
|
||||
&[
|
||||
r##"href="./first/nested.html#some-section" id="some-section""##,
|
||||
r##"href="first/nested.html#some-section" id="some-section""##,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue