cdocparser
Advanced tools
Comparing version 0.13.0 to 0.14.0
19
index.js
@@ -8,2 +8,3 @@ 'use strict'; | ||
var escapeStringRegexp = require('escape-string-regexp'); | ||
var union = require('lodash.union'); | ||
@@ -252,2 +253,7 @@ /** | ||
var isOverwritePoster = function(annotation){ | ||
return annotation.overwritePoster === true; | ||
}; | ||
var getContent = function(line, match){ | ||
@@ -372,5 +378,12 @@ return line.substr(match.index + match[0].length).replace(/^[ \t]+|[ \t]+$/g,''); | ||
Object.keys(posterComment).forEach(function(key){ | ||
if (parsedComment[key] === undefined && | ||
isAnnotationAllowed(parsedComment, annotations[key])){ | ||
parsedComment[key] = posterComment[key]; | ||
if (annotations[key] === undefined) return; | ||
var annotation = annotations[key]; | ||
if ( isAnnotationAllowed(parsedComment, annotation) ) { | ||
if (parsedComment[key] === undefined) { | ||
parsedComment[key] = posterComment[key]; | ||
} else if (isOverwritePoster(annotation)) { | ||
posterComment[key] = parsedComment[key]; | ||
} else { | ||
parsedComment[key] = union(posterComment[key], parsedComment[key]); | ||
} | ||
} | ||
@@ -377,0 +390,0 @@ }); |
{ | ||
"name": "cdocparser", | ||
"version": "0.13.0", | ||
"version": "0.14.0", | ||
"description": "Extract C style comments and extract context from source", | ||
@@ -31,4 +31,5 @@ "main": "index.js", | ||
"lodash.assign": "^2.4.1", | ||
"lodash.union": "^3.1.0", | ||
"strip-indent": "^1.0.0" | ||
} | ||
} |
@@ -165,3 +165,5 @@ CDocParser | ||
multiple : true | ||
multiple : true, | ||
overwritePoster : true | ||
} | ||
@@ -226,2 +228,6 @@ ``` | ||
### `overwritePoster` key | ||
The `overwritePoster` key is used to control if a this annotation used on an item will overwrite a poster comment. | ||
## Development | ||
@@ -228,0 +234,0 @@ |
@@ -221,2 +221,13 @@ var fs = require('fs'); | ||
}, | ||
poster : { | ||
parse : function(commentLine){ | ||
return commentLine; | ||
} | ||
}, | ||
posterOverwrite : { | ||
parse : function(commentLine){ | ||
return commentLine; | ||
}, | ||
overwritePoster: true | ||
}, | ||
multiline : { | ||
@@ -305,2 +316,10 @@ parse : function(commentLine){ | ||
it('should extend poster comments except for posterOverwrite `true`', function () { | ||
var comments = getCommentsFrom('posterOverwrite.test.scss'); | ||
var result = parser.parse ( comments ); | ||
assert.equal(result.length , 2); | ||
assert.deepEqual(result[1].poster , [ 'Poster', 'OnItem' ]); | ||
assert.deepEqual(result[1].posterOverwrite , [ 'OnItem' ]); | ||
}); | ||
it('should apply annotations in a line poster comment to each item', function () { | ||
@@ -307,0 +326,0 @@ var comments = getCommentsFrom('linePoster.test.scss'); |
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
45176
23
901
349
4
+ Addedlodash.union@^3.1.0
+ Addedlodash._baseflatten@3.1.4(transitive)
+ Addedlodash._baseindexof@3.1.0(transitive)
+ Addedlodash._baseuniq@3.0.3(transitive)
+ Addedlodash._cacheindexof@3.0.2(transitive)
+ Addedlodash._createcache@3.1.2(transitive)
+ Addedlodash._getnative@3.9.1(transitive)
+ Addedlodash.isarguments@3.1.0(transitive)
+ Addedlodash.isarray@3.0.4(transitive)
+ Addedlodash.restparam@3.6.1(transitive)
+ Addedlodash.union@3.1.0(transitive)