File tree 2 files changed +33
-2
lines changed
2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -145,4 +145,30 @@ describe('getPropType', () => {
145
145
} ) ;
146
146
} ) ;
147
147
148
+ it ( 'detects descriptions on nested types in shapes' , ( ) => {
149
+ expect ( getPropType ( expression ( `shape({
150
+ /**
151
+ * test1
152
+ */
153
+ foo: string,
154
+ /**
155
+ * test2
156
+ */
157
+ bar: bool
158
+ })` ) ) )
159
+ . toEqual ( {
160
+ name : 'shape' ,
161
+ value : {
162
+ foo : {
163
+ name : 'string' ,
164
+ description : 'test1' ,
165
+ } ,
166
+ bar : {
167
+ name : 'bool' ,
168
+ description : 'test2' ,
169
+ } ,
170
+ } ,
171
+ } ) ;
172
+ } ) ;
173
+
148
174
} ) ;
Original file line number Diff line number Diff line change 13
13
/*eslint no-use-before-define: 0*/
14
14
15
15
16
+ import { getDocblock } from '../utils/docblock' ;
16
17
import getMembers from './getMembers' ;
17
18
import getPropertyName from './getPropertyName' ;
18
19
import printValue from './printValue' ;
@@ -74,8 +75,12 @@ function getPropTypeShape(argumentPath) {
74
75
if ( types . ObjectExpression . check ( argumentPath . node ) ) {
75
76
type . value = { } ;
76
77
argumentPath . get ( 'properties' ) . each ( function ( propertyPath ) {
77
- type . value [ getPropertyName ( propertyPath ) ] =
78
- getPropType ( propertyPath . get ( 'value' ) ) ;
78
+ var descriptor = getPropType ( propertyPath . get ( 'value' ) , true ) ;
79
+ var docs = getDocblock ( propertyPath ) ;
80
+ if ( docs ) {
81
+ descriptor . description = docs ;
82
+ }
83
+ type . value [ getPropertyName ( propertyPath ) ] = descriptor ;
79
84
} ) ;
80
85
}
81
86
You can’t perform that action at this time.
0 commit comments