2011-12-20 16:15:49 -06:00
|
|
|
/* rustdoc: rust -> markdown translator
|
2011-12-20 16:19:46 -06:00
|
|
|
* Copyright 2011 Google Inc.
|
2011-12-20 15:52:04 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
use std;
|
|
|
|
use rustc;
|
|
|
|
|
|
|
|
import option;
|
|
|
|
import option::{some, none};
|
2012-01-13 19:33:16 -06:00
|
|
|
import rustc::driver::diagnostic;
|
2011-12-20 15:52:04 -06:00
|
|
|
import rustc::syntax::ast;
|
|
|
|
import rustc::syntax::codemap;
|
|
|
|
import rustc::syntax::parse::parser;
|
|
|
|
import rustc::syntax::print::pprust;
|
|
|
|
import rustc::syntax::visit;
|
|
|
|
import std::io;
|
2012-01-11 08:15:54 -06:00
|
|
|
import io::writer_util;
|
2011-12-20 15:52:04 -06:00
|
|
|
import std::map;
|
|
|
|
|
|
|
|
#[doc(
|
|
|
|
brief = "Main function.",
|
|
|
|
desc = "Command-line arguments:
|
|
|
|
|
|
|
|
* argv[1]: crate file name",
|
|
|
|
args(argv = "Command-line arguments.")
|
|
|
|
)]
|
|
|
|
fn main(argv: [str]) {
|
2011-12-30 17:26:49 -06:00
|
|
|
|
|
|
|
if vec::len(argv) != 2u {
|
2012-01-15 16:16:55 -06:00
|
|
|
io::println(#fmt("usage: %s <input>", argv[0]));
|
2011-12-30 17:26:49 -06:00
|
|
|
ret;
|
|
|
|
}
|
|
|
|
|
2012-01-16 03:03:41 -06:00
|
|
|
let source_file = argv[1];
|
|
|
|
let default_name = source_file;
|
|
|
|
let crate = parse::from_file(source_file);
|
|
|
|
let doc = extract::extract(crate, default_name);
|
|
|
|
gen::write_markdown(doc, crate, io::stdout());
|
2011-12-20 15:52:04 -06:00
|
|
|
}
|