angular-cn/public/doc-shredder/extractPathsReader.js
Jay Traband 6f6e83722e squashed commits for PR 222 from jtraband
- add warning when bad example tag is encountered.
- shredding for api docs + refactoring of gulpfile to clarify task names.
- added top level gulp tasks + error handling cleanup
- added test-api-builder gulp task
- added warning messages during build-shred-map processing
- mixin signature change
- updated styleguide ... continued.
- added @exampleTabs inlinetag support + refactoring shared services between @example and @exampleTabs
- added new inline tag @linkDevGuide + cleanup
- added angular source watch logic for serve-and-sync and source for examples changed from test -> examples + cleanup
- promisify del
- styleguide explanation of @example, @exampleTabs and @linkDevGuide
2015-09-23 14:04:58 -07:00

38 lines
998 B
JavaScript

/**
* @dgService extractPathsReader
* @description
*/
var path = require('canonical-path');
module.exports = function extractPathsReader(log) {
// regex for makeTabs line
var rx = /\s*\+make(?:=Tabs|Example|Json)\(\s*["'](.*?)["']\s*,\s*["'](.*?)["'].*?\)/g
return {
name: 'extractPathsReader',
// returns the fragment filePath without the _fragments dir on the front or the '.md'
getDocs: function (fileInfo) {
var content = fileInfo.content;
var fragItems = [];
var r;
while ((r = rx.exec(content)) !== null) {
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 } );
});
}
if (fragItems.length) {
return [{
fragItems: fragItems
}];
} else {
return [];
}
}
}
}