hydrolysis
Advanced tools
Comparing version 1.10.0 to 1.11.0
@@ -97,3 +97,2 @@ /** | ||
loader) { | ||
this.attachAST = attachAST; | ||
this.loader = loader; | ||
@@ -144,3 +143,2 @@ | ||
* @memberof hydrolysis | ||
* @property {boolean} attachAST Whether underlying AST data should be included. | ||
* @property {boolean} noAnnotations Whether `annotate()` should be skipped. | ||
@@ -176,3 +174,3 @@ * @property {boolean} clean Whether the generated descriptors should be cleaned | ||
var analyzer = new this(options.attachAST, loader); | ||
var analyzer = new this(null, loader); | ||
return analyzer.metadataTree(href).then(function(root) { | ||
@@ -289,8 +287,6 @@ if (!options.noAnnotations) { | ||
if (!src) { | ||
parsedJs = jsParse(script.childNodes[0].value, this.attachAST); | ||
parsedJs = jsParse(script.childNodes[0].value); | ||
if (parsedJs.elements) { | ||
parsedJs.elements.forEach(function(element) { | ||
if (this.attachAST) { | ||
element.scriptElement = script; | ||
} | ||
element.scriptElement = script; | ||
this.elements.push(element); | ||
@@ -297,0 +293,0 @@ if (element.is in this.elementsByTagName) { |
@@ -22,3 +22,3 @@ /** | ||
module.exports = function behaviorFinder(attachAST) { | ||
module.exports = function behaviorFinder() { | ||
/** @type {!Array<BehaviorDescriptor>} The behaviors we've found. */ | ||
@@ -42,2 +42,38 @@ var behaviors = []; | ||
/** | ||
* merges behavior with preexisting behavior with the same name. | ||
* here to support multiple @polymerBehavior tags referring | ||
* to same behavior. See iron-multi-selectable for example. | ||
*/ | ||
function mergeBehavior(newBehavior) { | ||
for (var i=0; i<behaviors.length; i++) { | ||
if (newBehavior.is !== behaviors[i].is) | ||
continue; | ||
// merge desc, longest desc wins | ||
if (newBehavior.desc) { | ||
if (behaviors[i].desc) { | ||
if (newBehavior.desc.length > behaviors[i].desc.length) | ||
behaviors[i].desc = newBehavior.desc; | ||
} | ||
else { | ||
behaviors[i].desc = newBehavior.desc; | ||
} | ||
} | ||
// merge demos | ||
behaviors[i].demos = (behaviors[i].demos || []).concat(newBehavior.demos || []); | ||
// merge events, | ||
behaviors[i].events = (behaviors[i].events || []).concat(newBehavior.events || []); | ||
// merge properties | ||
behaviors[i].properties = (behaviors[i].properties || []).concat(newBehavior.properties || []); | ||
// merge behaviors | ||
behaviors[i].behaviors = | ||
(behaviors[i].behaviors || []).concat(newBehavior.behaviors || []) | ||
.filter(function(b) { // filter out BehaviorImpl | ||
return b.indexOf(newBehavior.is) === -1; | ||
}); | ||
return behaviors[i]; | ||
} | ||
return newBehavior; | ||
} | ||
var visitors = { | ||
@@ -56,3 +92,3 @@ | ||
/** | ||
* Look for object assignments with @behavior in the docs. | ||
* Look for object assignments with @polymerBehavior in the docs. | ||
*/ | ||
@@ -94,2 +130,4 @@ enterAssignmentExpression: function(node, parent) { | ||
if (!comment || comment.indexOf('@polymerBehavior') === -1) return; | ||
currentBehavior = { | ||
@@ -120,2 +158,4 @@ type: 'behavior', | ||
this._parseChainedBehaviors(node); | ||
currentBehavior = mergeBehavior(currentBehavior); | ||
}, | ||
@@ -130,3 +170,3 @@ | ||
currentBehavior.properties = []; | ||
currentBehavior.properties = currentBehavior.properties || []; | ||
for (var i = 0; i < node.properties.length; i++) { | ||
@@ -133,0 +173,0 @@ var prop = node.properties[i]; |
@@ -241,4 +241,2 @@ /** | ||
if (!param) { | ||
// TODO(nevir): Plumb source locations through... | ||
console.warn('The JSDoc tag', tag.name, 'is not a param of', descriptor); | ||
return; | ||
@@ -245,0 +243,0 @@ } |
@@ -47,3 +47,3 @@ /** | ||
var jsParse = function jsParse(jsString, attachAST) { | ||
var jsParse = function jsParse(jsString) { | ||
var script = espree.parse(jsString, | ||
@@ -54,4 +54,4 @@ {attachComment: true, | ||
var featureInfo = featureFinder(attachAST); | ||
var behaviorInfo = behaviorFinder(attachAST); | ||
var featureInfo = featureFinder(); | ||
var behaviorInfo = behaviorFinder(); | ||
var elementInfo = elementFinder(); | ||
@@ -58,0 +58,0 @@ |
@@ -21,3 +21,3 @@ /** | ||
if (err) { | ||
throw err; | ||
deferred.reject(err); | ||
} else { | ||
@@ -29,4 +29,26 @@ deferred.resolve(content); | ||
/** | ||
* Returns true if `patha` is a sibling or aunt of `pathb`. | ||
* @return {boolean} | ||
*/ | ||
function isSiblingOrAunt(patha, pathb) { | ||
var parent = path.dirname(patha); | ||
if (pathb.indexOf(patha) === -1 && pathb.indexOf(parent) === 0) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
/** | ||
* Change `localPath` from a sibling of `basePath` to be a child of | ||
* `basePath` joined with `redirect`. | ||
* @return {string} | ||
*/ | ||
function redirectSibling(basePath, localPath, redirect) { | ||
var parent = path.dirname(basePath); | ||
var redirected = path.join(basePath, redirect, localPath.slice(parent.length)); | ||
return redirected; | ||
} | ||
/** | ||
* Resolves requests via the file system. | ||
@@ -42,2 +64,3 @@ * @constructor | ||
* current working directory. | ||
* @param {string} config.redirect Where to redirect lookups to siblings. | ||
*/ | ||
@@ -52,3 +75,4 @@ function FSResolver(config) { | ||
var base = this.config.basePath; | ||
var root = this.config.root; | ||
var root = this.config.root && path.normalize(this.config.root); | ||
var redirect = this.config.redirect; | ||
@@ -69,2 +93,6 @@ var local; | ||
if (redirect && isSiblingOrAunt(root, local)) { | ||
local = redirectSibling(root, local, redirect); | ||
} | ||
getFile(local, deferred); | ||
@@ -71,0 +99,0 @@ return true; |
{ | ||
"name": "hydrolysis", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"description": "Breaks polymers into monomers", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/Polymer/hydrolysis", |
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
73395
2138