react-docgen
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -16,4 +16,30 @@ /* | ||
var types = require('recast').types.namedTypes; | ||
var $__0= | ||
require('recast').types,NodePath=$__0.NodePath,builders=$__0.builders,types=$__0.namedTypes; | ||
function buildMemberExpressionFromPattern(path ) { | ||
var node = path.node; | ||
if (types.Property.check(node)) { | ||
var objPath = buildMemberExpressionFromPattern(path.parent); | ||
if (objPath) { | ||
return new NodePath( | ||
builders.memberExpression( | ||
objPath.node, | ||
node.key, | ||
types.Literal.check(node.key) | ||
), | ||
objPath | ||
); | ||
} | ||
} else if (types.ObjectPattern.check(node)) { | ||
return buildMemberExpressionFromPattern(path.parent); | ||
} else if (types.VariableDeclarator.check(node)) { | ||
return path.get('init'); | ||
} | ||
return null; | ||
} | ||
/** | ||
@@ -36,7 +62,18 @@ * If the path is an identifier, it is resolved in the scope chain. | ||
if (bindings.length > 0) { | ||
var parentPath = scope.getBindings()[node.name][0].parent; | ||
var resultPath = scope.getBindings()[node.name][0]; | ||
var parentPath = resultPath.parent; | ||
if (types.VariableDeclarator.check(parentPath.node)) { | ||
parentPath = parentPath.get('init'); | ||
resultPath = parentPath.get('init'); | ||
} else if (types.Property.check(parentPath.node)) { | ||
// must be inside a pattern | ||
var memberExpressionPath = buildMemberExpressionFromPattern( | ||
parentPath | ||
); | ||
if (memberExpressionPath) { | ||
return memberExpressionPath; | ||
} | ||
} | ||
return resolveToValue(parentPath); | ||
return resultPath.node !== path.node ? | ||
resolveToValue(resultPath) : | ||
path; | ||
} | ||
@@ -43,0 +80,0 @@ } |
{ | ||
"name": "react-docgen", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "A CLI and toolkit to extract information from React components for documentation generation.", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64106
1586