Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/book.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
use std::io::BufferedReader;
use std::iter::AdditiveIterator;

use regex::Regex;

pub struct BookItem {
pub title: String,
pub path: Path,
Expand Down
16 changes: 7 additions & 9 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ use book;
use book::{Book, BookItem};
use css;

use regex::Regex;

struct Build;

pub fn parse_cmd(name: &str) -> Option<Box<Subcommand>> {
Expand All @@ -37,7 +35,7 @@ fn write_toc(book: &Book, path_to_root: &Path, out: &mut Writer) -> IoResult<()>
item.title));
if !item.children.is_empty() {
try!(writeln!(out, "<ul class='section'>"));
walk_items(item.children[], section, path_to_root, out);
let _ = walk_items(item.children[], section, path_to_root, out);
try!(writeln!(out, "</ul>"));
}
try!(writeln!(out, "</li>"));
Expand Down Expand Up @@ -76,7 +74,7 @@ fn render(book: &Book, tgt: &Path) -> CliResult<()> {
let prelude = tmp.path().join("prelude.html");
{
let mut toc = BufferedWriter::new(try!(File::create(&prelude)));
write_toc(book, &item.path_to_root, &mut toc);
let _ = write_toc(book, &item.path_to_root, &mut toc);
try!(writeln!(&mut toc, "<div id='page-wrapper'>"));
try!(writeln!(&mut toc, "<div id='page'>"));
}
Expand All @@ -89,7 +87,7 @@ fn render(book: &Book, tgt: &Path) -> CliResult<()> {
}

let out_path = tgt.join(item.path.dirname());
try!(fs::mkdir_recursive(&out_path, io::UserDir));
try!(fs::mkdir_recursive(&out_path, io::USER_DIR));

let output_result = Command::new("rustdoc")
.arg(&preprocessed_path)
Expand Down Expand Up @@ -120,7 +118,7 @@ fn render(book: &Book, tgt: &Path) -> CliResult<()> {
}

impl Subcommand for Build {
fn parse_args(&mut self, args: &[String]) -> CliResult<()> {
fn parse_args(&mut self, _: &[String]) -> CliResult<()> {
Ok(())
}
fn usage(&self) {}
Expand All @@ -129,15 +127,15 @@ impl Subcommand for Build {
let src = cwd.clone();
let tgt = cwd.join("_book");

fs::mkdir(&tgt, io::UserDir); // FIXME: handle errors
let _ = fs::mkdir(&tgt, io::USER_DIR); // FIXME: handle errors

File::create(&tgt.join("rust-book.css")).write_str(css::STYLE); // FIXME: handle errors
let _ = File::create(&tgt.join("rust-book.css")).write_str(css::STYLE); // FIXME: handle errors

let summary = File::open(&src.join("SUMMARY.md"));
match book::parse_summary(summary, &src) {
Ok(book) => {
// execute rustdoc on the whole book
render(&book, &tgt).map_err(|err| {
let _ = render(&book, &tgt).map_err(|err| {
term.err(format!("error: {}", err.description())[]);
err.detail().map(|detail| {
term.err(format!("detail: {}", detail)[]);
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Error for String {
}

impl FromError<()> for () {
fn from_err(error: ()) -> () { () }
fn from_err(_: ()) -> () { () }
}

impl FromError<IoError> for IoError {
Expand Down
4 changes: 2 additions & 2 deletions src/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ pub fn parse_cmd(name: &str) -> Option<Box<Subcommand>> {
}

impl Subcommand for Help {
fn parse_args(&mut self, args: &[String]) -> CliResult<()> {
fn parse_args(&mut self, _: &[String]) -> CliResult<()> {
Ok(())
}
fn usage(&self) {}
fn execute(&mut self, term: &mut Term) {
fn execute(&mut self, _: &mut Term) {
usage()
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ mod test;

mod css;

#[cfg(not(test))] // thanks #12327
fn main() {
let mut term = Term::new();
let cmd = os::args();
Expand Down
4 changes: 2 additions & 2 deletions src/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ pub fn parse_cmd(name: &str) -> Option<Box<Subcommand>> {
}

impl Subcommand for Serve {
fn parse_args(&mut self, args: &[String]) -> CliResult<()> {
fn parse_args(&mut self, _: &[String]) -> CliResult<()> {
Ok(())
}
fn usage(&self) {}
fn execute(&mut self, term: &mut Term) {}
fn execute(&mut self, _: &mut Term) {}
}
10 changes: 0 additions & 10 deletions src/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,18 @@
//! verbosity support. For now, just a wrapper around stdout/stderr.

use std::io::stdio;
use std::io::IoResult;

pub struct Term {
verbose: bool,
out: Box<Writer + 'static>,
err: Box<Writer + 'static>
}

impl Term {
pub fn new() -> Term {
Term {
verbose: false,
out: box stdio::stdout() as Box<Writer>,
err: box stdio::stderr() as Box<Writer>,
}
}

pub fn out(&mut self, msg: &str) {
// swallow any errors
let _ = self.out.write_line(msg);
}

pub fn err(&mut self, msg: &str) {
// swallow any errors
let _ = self.err.write_line(msg);
Expand Down
4 changes: 2 additions & 2 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ pub fn parse_cmd(name: &str) -> Option<Box<Subcommand>> {
}

impl Subcommand for Test {
fn parse_args(&mut self, args: &[String]) -> CliResult<()> {
fn parse_args(&mut self, _: &[String]) -> CliResult<()> {
Ok(())
}
fn usage(&self) {}
fn execute(&mut self, term: &mut Term) {}
fn execute(&mut self, _: &mut Term) {}
}