cdocparser
Advanced tools
Comparing version
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'); |
45176
3.43%23
4.55%901
3.33%349
1.75%4
33.33%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added