rustdoc: Add parse::from_str for testing purposes
This commit is contained in:
parent
0e65ddfaea
commit
377316d8f6
@ -178,14 +178,26 @@ fn doc_header(rd: rustdoc, name: str) {
|
||||
}
|
||||
|
||||
mod parse {
|
||||
fn from_file(file: str) -> @ast::crate {
|
||||
export from_file, from_str;
|
||||
|
||||
fn new_parse_sess() -> parser::parse_sess {
|
||||
let cm = codemap::new_codemap();
|
||||
let sess = @{
|
||||
cm: cm,
|
||||
mutable next_id: 0,
|
||||
diagnostic: diagnostic::mk_handler(cm, none)
|
||||
};
|
||||
parser::parse_crate_from_source_file(file, [], sess)
|
||||
ret sess;
|
||||
}
|
||||
|
||||
fn from_file(file: str) -> @ast::crate {
|
||||
parser::parse_crate_from_source_file(
|
||||
file, [], new_parse_sess())
|
||||
}
|
||||
|
||||
fn from_str(source: str) -> @ast::crate {
|
||||
parser::parse_crate_from_source_str(
|
||||
"-", source, [], new_parse_sess())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user