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

62 lines
1.4 KiB
JavaScript
Raw Normal View History

/**
* @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;
switch (fileInfo.extension) {
case 'ts':
case 'js':
case 'dart':
2015-10-14 15:47:22 -04:00
commentInfo = {
prefix: '//',
blockPattern: '/* {tag} */'
};
//commentMarkers = ['//'];
break;
case 'html':
2015-10-14 15:47:22 -04:00
commentInfo = {
prefix: '<!--',
blockPattern: '<!-- {tag} -->'
};
// commentMarkers = ['<!--'];
break;
case 'css':
2015-10-14 15:47:22 -04:00
commentInfo = {
prefix: '/*',
blockPattern: '/* {tag} */'
};
// commentMarkers = ['/*'];
break;
case 'json':
break;
case 'yaml':
2015-10-14 15:47:22 -04:00
commentInfo = {
prefix: '#',
blockPattern: '# {tag} '
};
// commentMarkers = ['#'];
break;
default:
2015-10-14 15:47:22 -04:00
return {};
}
var docs;
// log.info("fileShredder processing: " + fileInfo.relativePath);
2015-10-14 15:47:22 -04:00
if (commentInfo) {
docs = regionExtractor(fileInfo.content, commentInfo);
} else {
docs = [ { content: fileInfo.content } ];
}
if (docs.length) {
log.info("shredded file: " + fileInfo.relativePath);
}
return docs;
}
}
}