Skip to content

Commit d9efb2f

Browse files
committed
---
yaml --- r: 7302 b: refs/heads/master c: f3c4263 h: refs/heads/master v: v3
1 parent a7724f3 commit d9efb2f

File tree

4 files changed

+71
-68
lines changed

4 files changed

+71
-68
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 46a662ecb21eac21bd274bc23e5faf9cf51790be
2+
refs/heads/master: f3c42636357a2757d9a01871580cb660418ca77e

trunk/src/rustdoc/attr_parser.rs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
export parse_compound_fndoc;
2+
3+
#[doc(
4+
brief = "Parses function docs from a complex #[doc] attribute.",
5+
desc = "Supported attributes:
6+
7+
* `brief`: Brief description
8+
* `desc`: Long description
9+
* `return`: Description of return value
10+
* `args`: List of argname = argdesc pairs
11+
",
12+
args(items = "Doc attribute contents"),
13+
return = "Parsed function docs."
14+
)]
15+
fn parse_compound_fndoc(items: [@ast::meta_item]) -> doc::fndoc {
16+
let brief = none;
17+
let desc = none;
18+
let return = none;
19+
let argdocs = map::new_str_hash::<str>();
20+
let argdocsfound = none;
21+
for item: @ast::meta_item in items {
22+
alt item.node {
23+
ast::meta_name_value("brief", {node: ast::lit_str(value),
24+
span: _}) {
25+
brief = some(value);
26+
}
27+
ast::meta_name_value("desc", {node: ast::lit_str(value),
28+
span: _}) {
29+
desc = some(value);
30+
}
31+
ast::meta_name_value("return", {node: ast::lit_str(value),
32+
span: _}) {
33+
return = some(value);
34+
}
35+
ast::meta_list("args", args) {
36+
argdocsfound = some(args);
37+
}
38+
_ { }
39+
}
40+
}
41+
42+
alt argdocsfound {
43+
none. { }
44+
some(ds) {
45+
for d: @ast::meta_item in ds {
46+
alt d.node {
47+
ast::meta_name_value(key, {node: ast::lit_str(value),
48+
span: _}) {
49+
argdocs.insert(key, value);
50+
}
51+
}
52+
}
53+
}
54+
}
55+
56+
let _brief = alt brief {
57+
some(_b) { _b }
58+
none. { "_undocumented_" }
59+
};
60+
61+
~{
62+
name: "todo",
63+
brief: _brief,
64+
desc: desc,
65+
return: return,
66+
args: argdocs }
67+
}

trunk/src/rustdoc/rustdoc.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99

1010
mod parse;
1111
mod extract;
12+
mod attr_parser;
1213
mod doc;
1314
mod gen;

trunk/src/rustdoc/rustdoc.rs

Lines changed: 2 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -22,72 +22,6 @@ type rustdoc = {
2222
w: io::writer
2323
};
2424

25-
#[doc(
26-
brief = "Parses function docs from a complex #[doc] attribute.",
27-
desc = "Supported attributes:
28-
29-
* `brief`: Brief description
30-
* `desc`: Long description
31-
* `return`: Description of return value
32-
* `args`: List of argname = argdesc pairs
33-
",
34-
args(items = "Doc attribute contents"),
35-
return = "Parsed function docs."
36-
)]
37-
fn parse_compound_fndoc(items: [@ast::meta_item]) -> doc::fndoc {
38-
let brief = none;
39-
let desc = none;
40-
let return = none;
41-
let argdocs = map::new_str_hash::<str>();
42-
let argdocsfound = none;
43-
for item: @ast::meta_item in items {
44-
alt item.node {
45-
ast::meta_name_value("brief", {node: ast::lit_str(value),
46-
span: _}) {
47-
brief = some(value);
48-
}
49-
ast::meta_name_value("desc", {node: ast::lit_str(value),
50-
span: _}) {
51-
desc = some(value);
52-
}
53-
ast::meta_name_value("return", {node: ast::lit_str(value),
54-
span: _}) {
55-
return = some(value);
56-
}
57-
ast::meta_list("args", args) {
58-
argdocsfound = some(args);
59-
}
60-
_ { }
61-
}
62-
}
63-
64-
alt argdocsfound {
65-
none. { }
66-
some(ds) {
67-
for d: @ast::meta_item in ds {
68-
alt d.node {
69-
ast::meta_name_value(key, {node: ast::lit_str(value),
70-
span: _}) {
71-
argdocs.insert(key, value);
72-
}
73-
}
74-
}
75-
}
76-
}
77-
78-
let _brief = alt brief {
79-
some(_b) { _b }
80-
none. { "_undocumented_" }
81-
};
82-
83-
~{
84-
name: "todo",
85-
brief: _brief,
86-
desc: desc,
87-
return: return,
88-
args: argdocs }
89-
}
90-
9125
#[doc(
9226
brief = "Documents a single crate item.",
9327
args(rd = "Rustdoc context",
@@ -109,7 +43,8 @@ fn doc_item(rd: rustdoc, item: @ast::item) {
10943
});
11044
}
11145
ast::meta_list("doc", docs) {
112-
_fndoc = some(parse_compound_fndoc(docs));
46+
_fndoc = some(
47+
attr_parser::parse_compound_fndoc(docs));
11348
}
11449
}
11550
}

0 commit comments

Comments
 (0)