1 | 'use strict';
|
2 | var eol = require('eol');
|
3 | var commentsUtil = require('../utils/comments');
|
4 |
|
5 | module.exports = function (params) {
|
6 | params = params || {};
|
7 | var regex = commentsUtil.getRegex(params.customTags);
|
8 | var commentsRegex = new RegExp('^\\s*--' + regex + '$', 'mig');
|
9 |
|
10 | return function parse(contents, file) {
|
11 | var comments = [];
|
12 |
|
13 | eol.split(contents).forEach(function (line, index) {
|
14 | var match = commentsRegex.exec(line);
|
15 | var comment = commentsUtil.prepareComment(match, index + 1, file);
|
16 | if (!comment) {
|
17 | return;
|
18 | }
|
19 | comments.push(comment);
|
20 | });
|
21 | return comments;
|
22 | };
|
23 | };
|