-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathparser.js
39 lines (30 loc) · 930 Bytes
/
parser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict';
var logger = require('./log');
var AnnotationApi = require('./annotation');
var ScssCommentParser = require('scss-comment-parser');
var Parser = function(){
this.annotations = new AnnotationApi();
this.scssParser = new ScssCommentParser(this.annotations.list);
this.scssParser.commentParser.on('warning', function (warning) {
logger.warn(warning);
});
};
Parser.prototype = {
parse: function(){
return this.scssParser.parse.apply(this.scssParser, arguments);
},
/**
* Invoke the `resolve` function of an annotation if present.
* Called with all found annotations except with type "unkown".
*/
postProcess: function(data){
Object.keys(this.annotations.list).forEach(function (key) {
var annotation = this.annotations.list[key];
if (annotation.resolve) {
annotation.resolve(data);
}
}, this);
return data;
}
};
module.exports = Parser;