angular-cn/public/doc-shredder/extractPathsReader.js

36 lines
800 B
JavaScript
Raw Normal View History

2015-08-10 14:17:02 -04:00
/**
2015-08-11 03:27:09 -04:00
* @dgService extractPathsReader
2015-08-10 14:17:02 -04:00
* @description
*/
var path = require('canonical-path');
module.exports = function extractPathsReader(log) {
2015-08-11 03:27:09 -04:00
// regex for makeTabs line
var rx = /\s*\+make(?:=Tabs|Example)\(\s*["'](.*?)["']\s*,\s*["'](.*?)["'].*?\)/g
2015-08-10 14:17:02 -04:00
return {
name: 'extractPathsReader',
getDocs: function (fileInfo) {
var content = fileInfo.content;
2015-08-11 03:27:09 -04:00
var fragPaths = [];
2015-08-10 14:17:02 -04:00
var r;
while ((r = rx.exec(content)) !== null) {
var basePath = r[1];
var fileNames = r[2].split(',');
fileNames.forEach(function(fn) {
2015-08-11 03:27:09 -04:00
fragPaths.push(path.join(basePath, fn.trim()));
2015-08-10 14:17:02 -04:00
})
}
2015-08-11 03:27:09 -04:00
if (fragPaths.length) {
2015-08-10 14:17:02 -04:00
return [{
2015-08-11 03:27:09 -04:00
fragPaths: fragPaths
2015-08-10 14:17:02 -04:00
}];
} else {
return [];
}
}
}
}