-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathparser.js
35 lines (29 loc) · 957 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
let AnnotationsApi = require('./annotation').default;
let ScssCommentParser = require('scss-comment-parser');
export default class Parser {
constructor(config, additionalAnnotations) {
console.log(AnnotationsApi);
this.annotations = new AnnotationsApi(config);
this.annotations.addAnnotations(additionalAnnotations);
this.scssParser = new ScssCommentParser(this.annotations.list, config);
this.scssParser.commentParser.on('warning', warning => {
config.logger.warn(warning);
});
}
parse(code) {
return this.scssParser.parse(code);
}
/**
* Invoke the `resolve` function of an annotation if present.
* Called with all found annotations except with type "unkown".
*/
postProcess(data) {
Object.keys(this.annotations.list).forEach(key => {
let annotation = this.annotations.list[key];
if (annotation.resolve) {
annotation.resolve(data);
}
});
return data;
}
}