@@ -10,12 +10,7 @@ var flatteners = {
10
10
'alias' : flattenName ,
11
11
'arg' : synonym ( 'param' ) ,
12
12
'argument' : synonym ( 'param' ) ,
13
- 'augments' : function ( result , tag ) {
14
- if ( ! result . augments ) {
15
- result . augments = [ ] ;
16
- }
17
- result . augments . push ( tag ) ;
18
- } ,
13
+ 'augments' : collect ( 'augments' ) ,
19
14
'author' : flattenDescription ,
20
15
'borrows' : todo ,
21
16
'callback' : flattenDescription ,
@@ -103,22 +98,12 @@ var flatteners = {
103
98
'namespace' : flattenTypedName ,
104
99
'override' : flattenBoolean ,
105
100
'overview' : synonym ( 'file' ) ,
106
- 'param' : function ( result , tag ) {
107
- if ( ! result . params ) {
108
- result . params = [ ] ;
109
- }
110
- result . params . push ( tag ) ;
111
- } ,
101
+ 'param' : collect ( 'params' ) ,
112
102
'private' : function ( result ) {
113
103
result . access = 'private' ;
114
104
} ,
115
105
'prop' : synonym ( 'property' ) ,
116
- 'property' : function ( result , tag ) {
117
- if ( ! result . properties ) {
118
- result . properties = [ ] ;
119
- }
120
- result . properties . push ( tag ) ;
121
- } ,
106
+ 'property' : collect ( 'properties' ) ,
122
107
'protected' : function ( result ) {
123
108
result . access = 'protected' ;
124
109
} ,
@@ -128,36 +113,16 @@ var flatteners = {
128
113
'readonly' : flattenBoolean ,
129
114
'requires' : todo ,
130
115
'return' : synonym ( 'returns' ) ,
131
- 'returns' : function ( result , tag ) {
132
- if ( ! result . returns ) {
133
- result . returns = [ ] ;
134
- }
135
- result . returns . push ( tag ) ;
136
- } ,
137
- 'see' : function ( result , tag ) {
138
- if ( ! result . sees ) {
139
- result . sees = [ ] ;
140
- }
141
- result . sees . push ( tag . description ) ;
142
- } ,
116
+ 'returns' : collect ( 'returns' ) ,
117
+ 'see' : collect ( 'sees' , true ) ,
143
118
'since' : flattenDescription ,
144
119
'static' : function ( result ) {
145
120
result . scope = 'static' ;
146
121
} ,
147
122
'summary' : flattenDescription ,
148
123
'this' : todo ,
149
- 'throws' : function ( result , tag ) {
150
- if ( ! result . throws ) {
151
- result . throws = [ ] ;
152
- }
153
- result . throws . push ( tag ) ;
154
- } ,
155
- 'todo' : function ( result , tag ) {
156
- if ( ! result . todos ) {
157
- result . todos = [ ] ;
158
- }
159
- result . todos . push ( tag . description ) ;
160
- } ,
124
+ 'throws' : collect ( 'throws' ) ,
125
+ 'todo' : collect ( 'todos' , true ) ,
161
126
'tutorial' : todo ,
162
127
'type' : todo ,
163
128
'typedef' : flattenTypedName ,
@@ -171,6 +136,19 @@ var flatteners = {
171
136
172
137
function todo ( ) { }
173
138
139
+ function collect ( key , description ) {
140
+ return function ( result , tag ) {
141
+ if ( ! result [ key ] ) {
142
+ result [ key ] = [ ] ;
143
+ }
144
+ if ( description ) {
145
+ result [ key ] . push ( tag . description ) ;
146
+ } else {
147
+ result [ key ] . push ( tag ) ;
148
+ }
149
+ } ;
150
+ }
151
+
174
152
function synonym ( key ) {
175
153
return function ( result , tag ) {
176
154
return flatteners [ key ] ( result , tag , key ) ;
0 commit comments