@@ -10,12 +10,7 @@ var flatteners = {
1010 'alias' : flattenName ,
1111 'arg' : synonym ( 'param' ) ,
1212 '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' ) ,
1914 'author' : flattenDescription ,
2015 'borrows' : todo ,
2116 'callback' : flattenDescription ,
@@ -103,22 +98,12 @@ var flatteners = {
10398 'namespace' : flattenTypedName ,
10499 'override' : flattenBoolean ,
105100 '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' ) ,
112102 'private' : function ( result ) {
113103 result . access = 'private' ;
114104 } ,
115105 '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' ) ,
122107 'protected' : function ( result ) {
123108 result . access = 'protected' ;
124109 } ,
@@ -128,36 +113,16 @@ var flatteners = {
128113 'readonly' : flattenBoolean ,
129114 'requires' : todo ,
130115 '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 ) ,
143118 'since' : flattenDescription ,
144119 'static' : function ( result ) {
145120 result . scope = 'static' ;
146121 } ,
147122 'summary' : flattenDescription ,
148123 '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 ) ,
161126 'tutorial' : todo ,
162127 'type' : todo ,
163128 'typedef' : flattenTypedName ,
@@ -171,6 +136,19 @@ var flatteners = {
171136
172137function todo ( ) { }
173138
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+
174152function synonym ( key ) {
175153 return function ( result , tag ) {
176154 return flatteners [ key ] ( result , tag , key ) ;
0 commit comments