rustdoc: Rename type rustdoc to gen::ctxt
This commit is contained in:
parent
906a7c2174
commit
7a9ba240a0
@ -1,4 +1,4 @@
|
||||
type rustdoc = {
|
||||
type ctxt = {
|
||||
ps: pprust::ps,
|
||||
w: io::writer
|
||||
};
|
||||
@ -8,8 +8,8 @@
|
||||
args(rd = "Rustdoc context",
|
||||
name = "Crate name")
|
||||
)]
|
||||
fn write_header(rd: rustdoc, name: str) {
|
||||
rd.w.write_line("# Crate " + name);
|
||||
fn write_header(ctxt: ctxt, name: str) {
|
||||
ctxt.w.write_line("# Crate " + name);
|
||||
}
|
||||
|
||||
#[doc(
|
||||
@ -19,30 +19,30 @@ fn write_header(rd: rustdoc, name: str) {
|
||||
doc = "Function docs extracted from attributes",
|
||||
_fn = "AST object representing this function")
|
||||
)]
|
||||
fn write_fndoc(rd: rustdoc, ident: str, doc: doc::fndoc, decl: ast::fn_decl) {
|
||||
rd.w.write_line("## Function `" + ident + "`");
|
||||
rd.w.write_line(doc.brief);
|
||||
fn write_fndoc(ctxt: ctxt, ident: str, doc: doc::fndoc, decl: ast::fn_decl) {
|
||||
ctxt.w.write_line("## Function `" + ident + "`");
|
||||
ctxt.w.write_line(doc.brief);
|
||||
alt doc.desc {
|
||||
some(_d) {
|
||||
rd.w.write_line("");
|
||||
rd.w.write_line(_d);
|
||||
rd.w.write_line("");
|
||||
ctxt.w.write_line("");
|
||||
ctxt.w.write_line(_d);
|
||||
ctxt.w.write_line("");
|
||||
}
|
||||
none. { }
|
||||
}
|
||||
for arg: ast::arg in decl.inputs {
|
||||
rd.w.write_str("### Argument `" + arg.ident + "`: ");
|
||||
rd.w.write_line("`" + pprust::ty_to_str(arg.ty) + "`");
|
||||
ctxt.w.write_str("### Argument `" + arg.ident + "`: ");
|
||||
ctxt.w.write_line("`" + pprust::ty_to_str(arg.ty) + "`");
|
||||
alt doc.args.find(arg.ident) {
|
||||
some(_d) {
|
||||
rd.w.write_line(_d);
|
||||
ctxt.w.write_line(_d);
|
||||
}
|
||||
none. { }
|
||||
};
|
||||
}
|
||||
rd.w.write_line("### Returns `" + pprust::ty_to_str(decl.output) + "`");
|
||||
ctxt.w.write_line("### Returns `" + pprust::ty_to_str(decl.output) + "`");
|
||||
alt doc.return {
|
||||
some(_r) { rd.w.write_line(_r); }
|
||||
some(_r) { ctxt.w.write_line(_r); }
|
||||
none. { }
|
||||
}
|
||||
}
|
||||
|
@ -17,23 +17,18 @@
|
||||
import io::writer_util;
|
||||
import std::map;
|
||||
|
||||
type rustdoc = {
|
||||
ps: pprust::ps,
|
||||
w: io::writer
|
||||
};
|
||||
|
||||
#[doc(
|
||||
brief = "Documents a single crate item.",
|
||||
args(rd = "Rustdoc context",
|
||||
item = "AST item to document")
|
||||
)]
|
||||
fn doc_item(rd: rustdoc, item: @ast::item) {
|
||||
fn doc_item(ctxt: gen::ctxt, item: @ast::item) {
|
||||
let _fndoc0 = attr_parser::parse_fn(item.ident, item.attrs);
|
||||
|
||||
alt item.node {
|
||||
ast::item_const(ty, expr) { }
|
||||
ast::item_fn(decl, _, _) {
|
||||
gen::write_fndoc(rd, item.ident, _fndoc0, decl);
|
||||
gen::write_fndoc(ctxt, item.ident, _fndoc0, decl);
|
||||
}
|
||||
ast::item_mod(_mod) { }
|
||||
ast::item_ty(ty, typarams) { }
|
||||
@ -59,11 +54,11 @@ fn main(argv: [str]) {
|
||||
let crate = parse::from_file(argv[1]);
|
||||
|
||||
let w = io::stdout();
|
||||
let rd = { ps: pprust::rust_printer(w), w: w };
|
||||
gen::write_header(rd, argv[1]);
|
||||
let ctxt = { ps: pprust::rust_printer(w), w: w };
|
||||
gen::write_header(ctxt, argv[1]);
|
||||
|
||||
let v = visit::mk_simple_visitor(@{
|
||||
visit_item: bind doc_item(rd, _)
|
||||
visit_item: bind doc_item(ctxt, _)
|
||||
with *visit::default_simple_visitor()});
|
||||
visit::visit_crate(*crate, (), v);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user