2015-08-06 12:38:48 +02:00
|
|
|
# Rust Library
|
|
|
|
|
|
|
|
|
|
mdBook is not only a command line tool, it can be used as a crate. You can extend it,
|
|
|
|
|
integrate it in current projects. Here is a short example:
|
|
|
|
|
|
2015-12-29 17:59:08 -05:00
|
|
|
```rust,ignore
|
2015-08-06 15:24:34 +02:00
|
|
|
extern crate mdbook;
|
2015-08-06 12:38:48 +02:00
|
|
|
|
2015-08-06 15:24:34 +02:00
|
|
|
use mdbook::MDBook;
|
2015-08-06 14:09:55 +02:00
|
|
|
use std::path::Path;
|
2015-08-06 12:38:48 +02:00
|
|
|
|
2017-06-06 11:58:08 +02:00
|
|
|
# #[allow(unused_variables)]
|
2015-08-06 12:38:48 +02:00
|
|
|
fn main() {
|
2017-06-06 11:58:08 +02:00
|
|
|
let mut book = MDBook::new("my-book") // Path to root
|
|
|
|
|
.with_source("src") // Path from root to source directory
|
|
|
|
|
.with_destination("book") // Path from root to output directory
|
|
|
|
|
.read_config() // Parse book.toml or book.json configuration file
|
|
|
|
|
.expect("I don't handle configuration file error, but you should!");
|
2015-08-06 12:38:48 +02:00
|
|
|
|
2017-06-06 11:58:08 +02:00
|
|
|
book.build().unwrap(); // Render the book
|
2015-08-06 12:38:48 +02:00
|
|
|
}
|
|
|
|
|
```
|
2015-08-06 21:10:59 +02:00
|
|
|
|
2017-05-01 20:31:03 -04:00
|
|
|
Check here for the [API docs](mdbook/index.html) generated by rustdoc.
|