2015-08-06 18:38:48 +08:00
|
|
|
//! # mdBook
|
|
|
|
//!
|
|
|
|
//! **mdBook** is similar to Gitbook but implemented in Rust.
|
|
|
|
//! It offers a command line interface, but can also be used as a regular crate.
|
|
|
|
//!
|
|
|
|
//! This is the API doc, but you can find a [less "low-level" documentation here](../index.html) that
|
|
|
|
//! contains information about the command line tool, format, structure etc.
|
|
|
|
//! It is also rendered with mdBook to showcase the features and default theme.
|
|
|
|
//!
|
|
|
|
//! Some reasons why you would want to use the crate (over the cli):
|
|
|
|
//!
|
|
|
|
//! - Integrate mdbook in a current project
|
|
|
|
//! - Extend the capabilities of mdBook
|
|
|
|
//! - Do some processing or test before building your book
|
|
|
|
//! - Write a new Renderer
|
|
|
|
//! - ...
|
|
|
|
//!
|
|
|
|
//! ## Example
|
|
|
|
//!
|
2015-08-06 21:04:27 +08:00
|
|
|
//! ```no_run
|
2015-08-06 18:38:48 +08:00
|
|
|
//! extern crate mdbook;
|
|
|
|
//!
|
|
|
|
//! use mdbook::MDBook;
|
2015-08-06 18:52:06 +08:00
|
|
|
//! use std::path::Path;
|
2015-08-06 18:38:48 +08:00
|
|
|
//!
|
|
|
|
//! fn main() {
|
2015-08-07 03:10:59 +08:00
|
|
|
//! let mut book = MDBook::new(Path::new("my-book")) // Path to root
|
|
|
|
//! .set_src(Path::new("src")) // Path from root to source directory
|
|
|
|
//! .set_dest(Path::new("book")) // Path from root to output directory
|
|
|
|
//! .read_config(); // Parse book.json file for configuration
|
2015-08-06 18:38:48 +08:00
|
|
|
//!
|
2015-08-07 03:10:59 +08:00
|
|
|
//! book.build().unwrap(); // Render the book
|
2015-08-06 18:38:48 +08:00
|
|
|
//! }
|
|
|
|
//! ```
|
|
|
|
//!
|
|
|
|
//! ## Implementing a new Renderer
|
|
|
|
//!
|
|
|
|
//! If you want to create a new renderer for mdBook, the only thing you have to do is to implement
|
|
|
|
//! the [Renderer trait](renderer/renderer/trait.Renderer.html)
|
|
|
|
//!
|
|
|
|
//! And then you can swap in your renderer like this:
|
|
|
|
//!
|
2015-08-06 21:04:27 +08:00
|
|
|
//! ```no_run
|
|
|
|
//! # extern crate mdbook;
|
|
|
|
//! #
|
|
|
|
//! # use mdbook::MDBook;
|
|
|
|
//! # use mdbook::renderer::HtmlHandlebars;
|
|
|
|
//! # use std::path::Path;
|
|
|
|
//! #
|
|
|
|
//! # fn main() {
|
|
|
|
//! # let your_renderer = HtmlHandlebars::new();
|
|
|
|
//! #
|
|
|
|
//! let book = MDBook::new(Path::new("my-book")).set_renderer(Box::new(your_renderer));
|
|
|
|
//! # }
|
2015-08-06 18:38:48 +08:00
|
|
|
//! ```
|
2015-08-06 21:04:27 +08:00
|
|
|
//! If you make a renderer, you get the book constructed in form of `Vec<BookItems>` and you get
|
|
|
|
//! the book config in a `BookConfig` struct.
|
|
|
|
//!
|
|
|
|
//! It's your responsability to create the necessary files in the correct directories.
|
2015-08-07 03:10:59 +08:00
|
|
|
//!
|
|
|
|
//! ## utils
|
|
|
|
//!
|
|
|
|
//! I have regrouped some useful functions in the [utils](utils/index.html) module, like the following function
|
|
|
|
//!
|
|
|
|
//! ```ignore
|
2016-03-18 05:41:00 +08:00
|
|
|
//! utils::fs::create_path(path: &Path)
|
2015-08-07 03:10:59 +08:00
|
|
|
//! ```
|
|
|
|
//! This function creates all the directories in a given path if they do not exist
|
|
|
|
//!
|
|
|
|
//! Make sure to take a look at it.
|
2015-08-06 18:38:48 +08:00
|
|
|
|
2016-11-03 08:58:42 +08:00
|
|
|
extern crate serde;
|
|
|
|
extern crate serde_json;
|
2016-03-28 00:22:17 +08:00
|
|
|
extern crate handlebars;
|
|
|
|
extern crate pulldown_cmark;
|
|
|
|
|
2016-08-14 20:32:34 +08:00
|
|
|
#[macro_use] extern crate log;
|
2015-08-06 18:38:48 +08:00
|
|
|
pub mod book;
|
2015-07-18 06:04:20 +08:00
|
|
|
mod parse;
|
2015-07-19 06:08:38 +08:00
|
|
|
pub mod renderer;
|
|
|
|
pub mod theme;
|
2015-07-30 21:20:55 +08:00
|
|
|
pub mod utils;
|
2015-07-07 08:56:19 +08:00
|
|
|
|
2015-07-19 06:08:38 +08:00
|
|
|
pub use book::MDBook;
|
|
|
|
pub use book::BookItem;
|
|
|
|
pub use book::BookConfig;
|
2015-08-06 04:35:26 +08:00
|
|
|
pub use renderer::Renderer;
|