Moved the book examples to the top level lib.rs
This commit is contained in:
parent
be4654c9c2
commit
1b51cd244e
|
@ -1,39 +1,9 @@
|
||||||
//! The internal representation of a book and infrastructure for loading it from
|
//! The internal representation of a book and infrastructure for loading it from
|
||||||
//! disk and building it.
|
//! disk and building it.
|
||||||
//!
|
//!
|
||||||
//! # Examples
|
//! For examples on using `MDBook`, consult the [top-level documentation][1].
|
||||||
//!
|
//!
|
||||||
//! If creating a new book from scratch, you'll want to get a `BookBuilder` via
|
//! [1]: ../index.html
|
||||||
//! the `MDBook::init()` method.
|
|
||||||
//!
|
|
||||||
//! ```rust,no_run
|
|
||||||
//! use mdbook::MDBook;
|
|
||||||
//! use mdbook::config::Config;
|
|
||||||
//!
|
|
||||||
//! let root_dir = "/path/to/book/root";
|
|
||||||
//!
|
|
||||||
//! let mut cfg = Config::default();
|
|
||||||
//! cfg.book.title = Some("My Book".to_string());
|
|
||||||
//! cfg.book.authors.push("Michael-F-Bryan".to_string());
|
|
||||||
//!
|
|
||||||
//! MDBook::init(root_dir)
|
|
||||||
//! .create_gitignore(true)
|
|
||||||
//! .with_config(cfg)
|
|
||||||
//! .build()
|
|
||||||
//! .expect("Book generation failed");
|
|
||||||
//! ```
|
|
||||||
//!
|
|
||||||
//! You can also load an existing book and build it.
|
|
||||||
//!
|
|
||||||
//! ```rust,no_run
|
|
||||||
//! use mdbook::MDBook;
|
|
||||||
//!
|
|
||||||
//! let root_dir = "/path/to/book/root";
|
|
||||||
//!
|
|
||||||
//! let mut md = MDBook::load(root_dir)
|
|
||||||
//! .expect("Unable to load the book");
|
|
||||||
//! md.build().expect("Building failed");
|
|
||||||
//! ```
|
|
||||||
|
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
|
|
39
src/lib.rs
39
src/lib.rs
|
@ -15,24 +15,39 @@
|
||||||
//! - Write a new Renderer
|
//! - Write a new Renderer
|
||||||
//! - ...
|
//! - ...
|
||||||
//!
|
//!
|
||||||
//! ## Example
|
//! # Examples
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! If creating a new book from scratch, you'll want to get a `BookBuilder` via
|
||||||
//! extern crate mdbook;
|
//! the `MDBook::init()` method.
|
||||||
//!
|
//!
|
||||||
|
//! ```rust,no_run
|
||||||
//! use mdbook::MDBook;
|
//! use mdbook::MDBook;
|
||||||
//! use std::path::PathBuf;
|
//! use mdbook::config::Config;
|
||||||
//!
|
//!
|
||||||
//! fn main() {
|
//! let root_dir = "/path/to/book/root";
|
||||||
//! let mut md = MDBook::load("my-book").unwrap();
|
|
||||||
//!
|
//!
|
||||||
//! // tweak the book configuration a bit
|
//! // create a default config and change a couple things
|
||||||
//! md.config.book.src = PathBuf::from("source");
|
//! let mut cfg = Config::default();
|
||||||
//! md.config.build.build_dir = PathBuf::from("book");
|
//! cfg.book.title = Some("My Book".to_string());
|
||||||
|
//! cfg.book.authors.push("Michael-F-Bryan".to_string());
|
||||||
//!
|
//!
|
||||||
//! // Render the book
|
//! MDBook::init(root_dir)
|
||||||
//! md.build().unwrap();
|
//! .create_gitignore(true)
|
||||||
//! }
|
//! .with_config(cfg)
|
||||||
|
//! .build()
|
||||||
|
//! .expect("Book generation failed");
|
||||||
|
//! ```
|
||||||
|
//!
|
||||||
|
//! You can also load an existing book and build it.
|
||||||
|
//!
|
||||||
|
//! ```rust,no_run
|
||||||
|
//! use mdbook::MDBook;
|
||||||
|
//!
|
||||||
|
//! let root_dir = "/path/to/book/root";
|
||||||
|
//!
|
||||||
|
//! let mut md = MDBook::load(root_dir)
|
||||||
|
//! .expect("Unable to load the book");
|
||||||
|
//! md.build().expect("Building failed");
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! ## Implementing a new Renderer
|
//! ## Implementing a new Renderer
|
||||||
|
|
Loading…
Reference in New Issue