From 01fedcad77c77898ff955db1f052721493e486e2 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 15 Jan 2012 22:07:23 -0800 Subject: [PATCH] rustdoc: Change parse_fn to take a vector of attributes --- src/rustdoc/attr_parser.rs | 40 +++++++++++++++++++++++++++++++++++++- src/rustdoc/rustdoc.rs | 34 +------------------------------- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/src/rustdoc/attr_parser.rs b/src/rustdoc/attr_parser.rs index 2e8a48c5ee14..26d5849d2e52 100644 --- a/src/rustdoc/attr_parser.rs +++ b/src/rustdoc/attr_parser.rs @@ -1,5 +1,43 @@ export parse_fn; +fn parse_fn(attrs: [ast::attribute]) -> doc::fndoc { + let noargdocs = map::new_str_hash::(); + 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; diff --git a/src/rustdoc/rustdoc.rs b/src/rustdoc/rustdoc.rs index 94488841119b..2f8f4b4991b0 100755 --- a/src/rustdoc/rustdoc.rs +++ b/src/rustdoc/rustdoc.rs @@ -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::(); - 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) { }