use macros from the log crate, issue #151
This commit is contained in:
parent
a7ae0b99c4
commit
b584f6eb9c
|
@ -19,6 +19,7 @@ clap = "2.2.1"
|
||||||
handlebars = "0.20.0"
|
handlebars = "0.20.0"
|
||||||
rustc-serialize = "0.3.18"
|
rustc-serialize = "0.3.18"
|
||||||
pulldown-cmark = "0.0.8"
|
pulldown-cmark = "0.0.8"
|
||||||
|
log = "0.3"
|
||||||
|
|
||||||
# Watch feature
|
# Watch feature
|
||||||
notify = { version = "2.5.5", optional = true }
|
notify = { version = "2.5.5", optional = true }
|
||||||
|
|
|
@ -42,7 +42,7 @@ impl MDBook {
|
||||||
pub fn new(root: &Path) -> MDBook {
|
pub fn new(root: &Path) -> MDBook {
|
||||||
|
|
||||||
if !root.exists() || !root.is_dir() {
|
if !root.exists() || !root.is_dir() {
|
||||||
output!("{:?} No directory with that name", root);
|
info!("{:?} No directory with that name", root);
|
||||||
}
|
}
|
||||||
|
|
||||||
MDBook {
|
MDBook {
|
||||||
|
@ -116,7 +116,7 @@ impl MDBook {
|
||||||
|
|
||||||
if !self.root.exists() {
|
if !self.root.exists() {
|
||||||
fs::create_dir_all(&self.root).unwrap();
|
fs::create_dir_all(&self.root).unwrap();
|
||||||
output!("{:?} created", &self.root);
|
info!("{:?} created", &self.root);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,7 +73,7 @@ extern crate rustc_serialize;
|
||||||
extern crate handlebars;
|
extern crate handlebars;
|
||||||
extern crate pulldown_cmark;
|
extern crate pulldown_cmark;
|
||||||
|
|
||||||
#[macro_use] pub mod macros;
|
#[macro_use] extern crate log;
|
||||||
pub mod book;
|
pub mod book;
|
||||||
mod parse;
|
mod parse;
|
||||||
pub mod renderer;
|
pub mod renderer;
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
#[cfg(feature = "debug")]
|
|
||||||
macro_rules! debug {
|
|
||||||
($fmt:expr) => (println!($fmt));
|
|
||||||
($fmt:expr, $($arg:tt)*) => (println!($fmt, $($arg)*));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(feature = "debug"))]
|
|
||||||
macro_rules! debug {
|
|
||||||
($fmt:expr) => ();
|
|
||||||
($fmt:expr, $($arg:tt)*) => ();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "output")]
|
|
||||||
macro_rules! output {
|
|
||||||
($fmt:expr) => (println!($fmt));
|
|
||||||
($fmt:expr, $($arg:tt)*) => (println!($fmt, $($arg)*));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(feature = "output"))]
|
|
||||||
macro_rules! output {
|
|
||||||
($fmt:expr) => ();
|
|
||||||
($fmt:expr, $($arg:tt)*) => ();
|
|
||||||
}
|
|
|
@ -108,7 +108,7 @@ impl Renderer for HtmlHandlebars {
|
||||||
// Write to file
|
// Write to file
|
||||||
let mut file =
|
let mut file =
|
||||||
try!(utils::fs::create_file(&book.get_dest().join(&ch.path).with_extension("html")));
|
try!(utils::fs::create_file(&book.get_dest().join(&ch.path).with_extension("html")));
|
||||||
output!("[*] Creating {:?} ✓", &book.get_dest().join(&ch.path).with_extension("html"));
|
info!("[*] Creating {:?} ✓", &book.get_dest().join(&ch.path).with_extension("html"));
|
||||||
|
|
||||||
try!(file.write_all(&rendered.into_bytes()));
|
try!(file.write_all(&rendered.into_bytes()));
|
||||||
|
|
||||||
|
@ -130,8 +130,8 @@ impl Renderer for HtmlHandlebars {
|
||||||
|
|
||||||
try!(index_file.write_all(content.as_bytes()));
|
try!(index_file.write_all(content.as_bytes()));
|
||||||
|
|
||||||
output!("[*] Creating index.html from {:?} ✓",
|
info!("[*] Creating index.html from {:?} ✓",
|
||||||
book.get_dest().join(&ch.path.with_extension("html")));
|
book.get_dest().join(&ch.path.with_extension("html")));
|
||||||
index = false;
|
index = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ impl Renderer for HtmlHandlebars {
|
||||||
let rendered = try!(handlebars.render("index", &data));
|
let rendered = try!(handlebars.render("index", &data));
|
||||||
let mut file = try!(utils::fs::create_file(&book.get_dest().join("print").with_extension("html")));
|
let mut file = try!(utils::fs::create_file(&book.get_dest().join("print").with_extension("html")));
|
||||||
try!(file.write_all(&rendered.into_bytes()));
|
try!(file.write_all(&rendered.into_bytes()));
|
||||||
output!("[*] Creating print.html ✓");
|
info!("[*] Creating print.html ✓");
|
||||||
|
|
||||||
// Copy static files (js, css, images, ...)
|
// Copy static files (js, css, images, ...)
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub fn render_playpen(s: &str, path: &Path) -> String {
|
||||||
|
|
||||||
// Check if the file exists
|
// Check if the file exists
|
||||||
if !playpen.rust_file.exists() || !playpen.rust_file.is_file() {
|
if !playpen.rust_file.exists() || !playpen.rust_file.is_file() {
|
||||||
output!("[-] No file exists for {{{{#playpen }}}}\n {}", playpen.rust_file.to_str().unwrap());
|
info!("[-] No file exists for {{{{#playpen }}}}\n {}", playpen.rust_file.to_str().unwrap());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,9 +150,9 @@ pub fn copy_files_except_ext(from: &Path, to: &Path, recursive: bool, ext_blackl
|
||||||
debug!("[*] creating path for file: {:?}",
|
debug!("[*] creating path for file: {:?}",
|
||||||
&to.join(entry.path().file_name().expect("a file should have a file name...")));
|
&to.join(entry.path().file_name().expect("a file should have a file name...")));
|
||||||
|
|
||||||
output!("[*] Copying file: {:?}\n to {:?}",
|
info!("[*] Copying file: {:?}\n to {:?}",
|
||||||
entry.path(),
|
entry.path(),
|
||||||
&to.join(entry.path().file_name().expect("a file should have a file name...")));
|
&to.join(entry.path().file_name().expect("a file should have a file name...")));
|
||||||
try!(fs::copy(entry.path(),
|
try!(fs::copy(entry.path(),
|
||||||
&to.join(entry.path().file_name().expect("a file should have a file name..."))));
|
&to.join(entry.path().file_name().expect("a file should have a file name..."))));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue