@@ -109,14 +109,25 @@ var reactDocgenTemplate = Handlebars.compile('\
109
109
* Documentation generator using react-docgen *
110
110
********************************************************/
111
111
112
- var reactDocgenMarkdown = function ( componentSrc , options ) {
113
- var docs = reactDocs . parse ( componentSrc ) ;
114
- return reactDocgenTemplate ( {
115
- srcLink : options . srcLink ,
116
- componentName : options . componentName ,
117
- description : docs . description ,
118
- props : sortObjectByKey ( docs . props )
119
- } ) ;
112
+ var reactDocgenMarkdown = function ( componentSrc , options ) {
113
+ try {
114
+ const docs = reactDocs . parse ( componentSrc ) ;
115
+ return reactDocgenTemplate ( {
116
+ srcLink : options . srcLink ,
117
+ componentName : options . componentName ,
118
+ description : docs . description ,
119
+ props : sortObjectByKey ( docs . props )
120
+ } ) ;
121
+ } catch ( error ) {
122
+ // Fallback for components using multiple exports in the same file
123
+ const docsList = reactDocs . parse ( componentSrc , reactDocs . resolver . findAllExportedComponentDefinitions ) ;
124
+ return docsList . reduce ( ( acc , docs ) => acc + reactDocgenTemplate ( {
125
+ srcLink : options . srcLink ,
126
+ componentName : options . componentName ,
127
+ description : docs . description ,
128
+ props : sortObjectByKey ( docs . props )
129
+ } ) + '\n' , '' ) ;
130
+ }
120
131
} ;
121
132
122
133
module . exports = reactDocgenMarkdown ;
0 commit comments