@@ -36,27 +36,6 @@ mod test {
36
36
}
37
37
}
38
38
39
- fn doc_meta(
40
- attrs: ~[ast::attribute]
41
- ) -> Option<@ast::meta_item> {
42
-
43
- /*!
44
- * Given a vec of attributes, extract the meta_items contained in the \
45
- * doc attribute
46
- */
47
-
48
- let doc_metas = doc_metas(attrs);
49
- if vec::is_not_empty(doc_metas) {
50
- if vec::len(doc_metas) != 1u {
51
- warn!(" ignoring %u doc attributes", vec:: len ( doc_metas) - 1 u) ;
52
- }
53
- Some ( doc_metas[ 0 ] )
54
- } else {
55
- None
56
- }
57
-
58
- }
59
-
60
39
fn doc_metas(
61
40
attrs: ~[ast::attribute]
62
41
) -> ~[@ast::meta_item] {
@@ -102,11 +81,13 @@ fn should_not_extract_crate_name_if_no_name_value_in_link_attribute() {
102
81
}
103
82
104
83
fn parse_desc ( attrs : ~[ ast:: attribute ] ) -> Option < ~str > {
105
- match doc_meta ( attrs) {
106
- Some ( meta) => {
107
- attr:: get_meta_item_value_str ( meta)
108
- }
109
- None => None
84
+ let doc_strs = do doc_metas ( attrs) . filter_map |meta| {
85
+ attr:: get_meta_item_value_str ( * meta)
86
+ } ;
87
+ if doc_strs. is_empty ( ) {
88
+ None
89
+ } else {
90
+ Some ( str:: connect ( doc_strs, "\n " ) )
110
91
}
111
92
}
112
93
@@ -158,3 +139,12 @@ fn should_not_parse_non_hidden_attribute() {
158
139
let attrs = test:: parse_attributes ( source) ;
159
140
assert parse_hidden ( attrs) == false ;
160
141
}
142
+
143
+ #[ test]
144
+ fn should_concatenate_multiple_doc_comments ( ) {
145
+ let source = ~"/// foo\n /// bar";
146
+ let desc = parse_desc ( test:: parse_attributes ( source) ) ;
147
+ assert desc == Some ( ~"foo\n bar") ;
148
+ }
149
+
150
+
0 commit comments