rustdoc: Change parse_fn to take a vector of attributes

This commit is contained in:
Brian Anderson 2012-01-15 22:07:23 -08:00
parent d85fa7c8dc
commit 01fedcad77
2 changed files with 40 additions and 34 deletions

View File

@ -1,5 +1,43 @@
export parse_fn;
fn parse_fn(attrs: [ast::attribute]) -> doc::fndoc {
let noargdocs = map::new_str_hash::<str>();
let _fndoc = none;
for attr: ast::attribute in attrs {
alt attr.node.value.node {
ast::meta_name_value(
"doc", {node: ast::lit_str(value), span: _}) {
_fndoc = some(~{
name: "todo",
brief: value,
desc: none,
return: none,
args: noargdocs
});
}
ast::meta_list("doc", docs) {
_fndoc = some(
parse_fn_(docs));
}
}
}
let _fndoc0 = alt _fndoc {
some(_d) { _d }
none. {
~{
name: "todo",
brief: "_undocumented_",
desc: none,
return: none,
args: noargdocs
}
}
};
ret _fndoc0;
}
#[doc(
brief = "Parses function docs from a complex #[doc] attribute.",
desc = "Supported attributes:
@ -12,7 +50,7 @@ export parse_fn;
args(items = "Doc attribute contents"),
return = "Parsed function docs."
)]
fn parse_fn(items: [@ast::meta_item]) -> doc::fndoc {
fn parse_fn_(items: [@ast::meta_item]) -> doc::fndoc {
let brief = none;
let desc = none;
let return = none;

View File

@ -28,39 +28,7 @@ type rustdoc = {
item = "AST item to document")
)]
fn doc_item(rd: rustdoc, item: @ast::item) {
let _fndoc = none;
let noargdocs = map::new_str_hash::<str>();
for attr: ast::attribute in item.attrs {
alt attr.node.value.node {
ast::meta_name_value(
"doc", {node: ast::lit_str(value), span: _}) {
_fndoc = some(~{
name: "todo",
brief: value,
desc: none,
return: none,
args: noargdocs
});
}
ast::meta_list("doc", docs) {
_fndoc = some(
attr_parser::parse_fn(docs));
}
}
}
let _fndoc0 = alt _fndoc {
some(_d) { _d }
none. {
~{
name: "todo",
brief: "_undocumented_",
desc: none,
return: none,
args: noargdocs
}
}
};
let _fndoc0 = attr_parser::parse_fn(item.attrs);
alt item.node {
ast::item_const(ty, expr) { }