renamed directory + created BookItem
This commit is contained in:
parent
ad01c37432
commit
4fe0bc2de5
|
@ -0,0 +1,21 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
pub struct BookItem {
|
||||
name: String,
|
||||
path: PathBuf,
|
||||
sub_items: Vec<BookItem>,
|
||||
}
|
||||
|
||||
|
||||
impl BookItem {
|
||||
|
||||
fn new(name: String, path: PathBuf) -> Self {
|
||||
|
||||
BookItem {
|
||||
name: name,
|
||||
path: path,
|
||||
sub_items: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -3,10 +3,14 @@ use std::fs::{self, File, metadata};
|
|||
use std::io::Write;
|
||||
use std::io::Error;
|
||||
|
||||
use mdbook::bookconfig::BookConfig;
|
||||
use book::bookconfig::BookConfig;
|
||||
use book::bookitem::BookItem;
|
||||
|
||||
pub struct MDBook {
|
||||
title: String,
|
||||
author: String,
|
||||
config: BookConfig,
|
||||
pub content: Vec<BookItem>
|
||||
}
|
||||
|
||||
impl MDBook {
|
||||
|
@ -24,6 +28,9 @@ impl MDBook {
|
|||
}
|
||||
|
||||
MDBook {
|
||||
title: String::from(""),
|
||||
author: String::from(""),
|
||||
content: vec![],
|
||||
config: BookConfig::new()
|
||||
.set_src(path.join("src"))
|
||||
.set_dest(path.join("book")),
|
||||
|
@ -80,13 +87,15 @@ impl MDBook {
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
pub fn build(&self, dir: &PathBuf) -> Result<(), Error> {
|
||||
pub fn build(&self) -> Result<(), Error> {
|
||||
|
||||
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
// Builder functions
|
||||
pub fn set_dest(mut self, dest: PathBuf) -> Self {
|
||||
self.config = self.config.set_dest(dest);
|
||||
self
|
||||
|
@ -97,4 +106,14 @@ impl MDBook {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn set_title(mut self, title: String) -> Self {
|
||||
self.title = title;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_author(mut self, author: String) -> Self {
|
||||
self.author = author;
|
||||
self
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
pub mod mdbook;
|
||||
mod bookconfig;
|
||||
mod bookitem;
|
||||
|
||||
use self::bookconfig::BookConfig;
|
||||
use self::bookitem::BookItem;
|
|
@ -1,3 +1,3 @@
|
|||
mod mdbook;
|
||||
mod book;
|
||||
|
||||
pub use mdbook::mdbook::MDBook;
|
||||
pub use book::mdbook::MDBook;
|
||||
|
|
|
@ -146,7 +146,7 @@ fn build(args: Vec<String>) {
|
|||
let dir = std::env::current_dir().unwrap();
|
||||
let book = MDBook::new(&dir);
|
||||
|
||||
if let Err(e) = book.build(&dir) {
|
||||
if let Err(e) = book.build() {
|
||||
println!("Error: {}", e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
pub mod mdbook;
|
||||
mod bookconfig;
|
Loading…
Reference in New Issue