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
|
2015-09-18 22:51:10 -04:00
|
|
|
var rx = /\s*\+make(?:=Tabs|Example|Json)\(\s*["'](.*?)["']\s*,\s*["'](.*?)["'].*?\)/g
|
2015-08-10 14:17:02 -04:00
|
|
|
return {
|
|
|
|
name: 'extractPathsReader',
|
|
|
|
|
2015-09-18 22:51:10 -04:00
|
|
|
// returns the fragment filePath without the _fragments dir on the front or the '.md'
|
2015-08-10 14:17:02 -04:00
|
|
|
getDocs: function (fileInfo) {
|
|
|
|
var content = fileInfo.content;
|
2015-09-18 22:51:10 -04:00
|
|
|
var fragItems = [];
|
2015-08-10 14:17:02 -04:00
|
|
|
var r;
|
|
|
|
while ((r = rx.exec(content)) !== null) {
|
2015-09-18 22:51:10 -04:00
|
|
|
var filePaths = r[1].split(',');
|
|
|
|
var regions = (r.length > 2) ? r[2].split(",") : null;
|
|
|
|
filePaths.forEach(function(filePath, ix) {
|
|
|
|
var region = regions && regions[ix];
|
|
|
|
fragItems.push( { mixinPath: filePath, region: region } );
|
|
|
|
});
|
2015-08-10 14:17:02 -04:00
|
|
|
}
|
2015-09-18 22:51:10 -04:00
|
|
|
if (fragItems.length) {
|
2015-08-10 14:17:02 -04:00
|
|
|
return [{
|
2015-09-18 22:51:10 -04:00
|
|
|
fragItems: fragItems
|
2015-08-10 14:17:02 -04:00
|
|
|
}];
|
|
|
|
} else {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|