Add rustdoc generated API doc
This commit is contained in:
parent
01369ea42f
commit
e725215103
|
@ -13,3 +13,8 @@ pulldown-cmark = "*"
|
|||
default = ["output"]
|
||||
debug = []
|
||||
output = []
|
||||
|
||||
[[bin]]
|
||||
doc = false
|
||||
name = "mdbook"
|
||||
path = "src/bin/mdbook.rs"
|
||||
|
|
|
@ -10,4 +10,4 @@
|
|||
- [Theme](format/theme/theme.md)
|
||||
- [index.hbs](format/theme/index-hbs.md)
|
||||
- [Syntax highlighting](format/theme/syntax-highlighting.md)
|
||||
- [Rust Library]()
|
||||
- [Rust Library](lib/lib.md)
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# Rust Library
|
||||
|
||||
Check here for the [API docs](mdbook/index.html) generated by rustdoc
|
||||
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:
|
||||
|
||||
```rust
|
||||
extern crate mdBook;
|
||||
|
||||
use mdBook::MDBook;
|
||||
|
||||
fn main() {
|
||||
let book = MDBook::new("my-book") // Path to root
|
||||
.set_src("src") // Path from root to source directory
|
||||
.set_dest("book") // Path from root to output directory
|
||||
.read_config() // Parse book.json file for configuration
|
||||
|
||||
book.build().unwrap(); // Render the book
|
||||
}
|
||||
```
|
|
@ -5,10 +5,16 @@ set -o errexit -o nounset
|
|||
|
||||
rev=$(git rev-parse --short HEAD)
|
||||
|
||||
# Run cargo doc
|
||||
cargo doc
|
||||
|
||||
# Run mdbook to generate the book
|
||||
target/debug/mdbook build book-example/
|
||||
|
||||
cd book-example/book
|
||||
# Copy files from rendered book to doc root
|
||||
cp book-example/book/* target/doc/
|
||||
|
||||
cd target/doc
|
||||
|
||||
|
||||
git init
|
||||
|
|
48
src/lib.rs
48
src/lib.rs
|
@ -1,6 +1,52 @@
|
|||
//! # 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
|
||||
//!
|
||||
//! ```
|
||||
//! extern crate mdbook;
|
||||
//!
|
||||
//! use mdbook::MDBook;
|
||||
//!
|
||||
//! fn main() {
|
||||
//! let book = MDBook::new("my-book")
|
||||
//! .set_src("source_dir")
|
||||
//! .set_dest("output_dir")
|
||||
//! .read_config() // Reads book.json file for settings
|
||||
//!
|
||||
//! book.build().unwrap();
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! ## 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:
|
||||
//!
|
||||
//! ```ignore
|
||||
//! let book = MDBook::new("my-book").set_renderer(your_renderer)
|
||||
//! ```
|
||||
|
||||
|
||||
#[macro_use]
|
||||
pub mod macros;
|
||||
mod book;
|
||||
pub mod book;
|
||||
mod parse;
|
||||
pub mod renderer;
|
||||
pub mod theme;
|
||||
|
|
Loading…
Reference in New Issue