Skip to content

Commit

Permalink
fixed reactdoc parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
madushan1000 committed Oct 19, 2016
1 parent d383385 commit 9ac117c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ export default function ({types: t}) {
},
'FunctionDeclaration|FunctionExpression|ArrowFunctionExpression'(path, state) {
if(isStatelessComponent(path)) {
const className = path.parentPath.node.id.name;
let className = '';
if(path.parentPath.node.id) {
className = path.parentPath.node.id.name;
} else {
return;
}
injectReactDocgenInfo(className, path, state, this.file.code, t);
}
},
Expand Down Expand Up @@ -43,7 +48,13 @@ function injectReactDocgenInfo(className, path, state, code, t) {
return;
}

const docObj = reactDocs.parse(code);
let docObj = {};
try {
docObj = reactDocs.parse(code);
} catch(e) {
return;
}

const docNode = buildObjectExpression(docObj, t);
const docgenInfo = t.expressionStatement(
t.assignmentExpression(
Expand Down

0 comments on commit 9ac117c

Please sign in to comment.