2015-08-03 20:45:58 -04:00
|
|
|
/**
|
|
|
|
* @dgService htmlFileShredder
|
|
|
|
* @description
|
|
|
|
*/
|
|
|
|
module.exports = function fileShredder(log, regionExtractor) {
|
|
|
|
return {
|
|
|
|
name: 'fileShredder',
|
|
|
|
|
|
|
|
getDocs: function (fileInfo) {
|
2015-10-14 15:47:22 -04:00
|
|
|
var commentInfo;
|
2015-08-03 20:45:58 -04:00
|
|
|
switch (fileInfo.extension) {
|
|
|
|
case 'ts':
|
|
|
|
case 'js':
|
2015-10-13 17:01:43 -04:00
|
|
|
case 'dart':
|
2015-10-14 15:47:22 -04:00
|
|
|
commentInfo = {
|
|
|
|
prefix: '//',
|
|
|
|
blockPattern: '/* {tag} */'
|
|
|
|
};
|
|
|
|
//commentMarkers = ['//'];
|
2015-08-03 20:45:58 -04:00
|
|
|
break;
|
|
|
|
case 'html':
|
2015-10-14 15:47:22 -04:00
|
|
|
commentInfo = {
|
|
|
|
prefix: '<!--',
|
|
|
|
blockPattern: '<!-- {tag} -->'
|
|
|
|
};
|
|
|
|
// commentMarkers = ['<!--'];
|
2015-08-03 20:45:58 -04:00
|
|
|
break;
|
|
|
|
case 'css':
|
2015-10-14 15:47:22 -04:00
|
|
|
commentInfo = {
|
|
|
|
prefix: '/*',
|
|
|
|
blockPattern: '/* {tag} */'
|
|
|
|
};
|
|
|
|
// commentMarkers = ['/*'];
|
2015-08-03 20:45:58 -04:00
|
|
|
break;
|
2015-09-12 03:28:01 -04:00
|
|
|
case 'json':
|
|
|
|
break;
|
2015-10-13 17:01:43 -04:00
|
|
|
case 'yaml':
|
2015-10-14 15:47:22 -04:00
|
|
|
commentInfo = {
|
|
|
|
prefix: '#',
|
|
|
|
blockPattern: '# {tag} '
|
|
|
|
};
|
|
|
|
// commentMarkers = ['#'];
|
2015-10-13 17:01:43 -04:00
|
|
|
break;
|
2015-08-03 20:45:58 -04:00
|
|
|
default:
|
2015-10-14 15:47:22 -04:00
|
|
|
return {};
|
2015-08-03 20:45:58 -04:00
|
|
|
}
|
2015-09-18 22:51:10 -04:00
|
|
|
var docs;
|
|
|
|
// log.info("fileShredder processing: " + fileInfo.relativePath);
|
2015-10-14 15:47:22 -04:00
|
|
|
if (commentInfo) {
|
|
|
|
docs = regionExtractor(fileInfo.content, commentInfo);
|
2015-09-12 03:28:01 -04:00
|
|
|
} else {
|
2015-09-18 22:51:10 -04:00
|
|
|
docs = [ { content: fileInfo.content } ];
|
2015-09-12 03:28:01 -04:00
|
|
|
}
|
2015-09-18 22:51:10 -04:00
|
|
|
if (docs.length) {
|
|
|
|
log.info("shredded file: " + fileInfo.relativePath);
|
|
|
|
}
|
|
|
|
return docs;
|
2015-08-03 20:45:58 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|