remove basePath from docShredder options. Not useful and confusing when examplesDir and fragmentsDir don't share a basePath ( as when used for api shredding)

This commit is contained in:
Jay Traband 2015-09-18 07:20:02 -07:00
parent 39f1959f2e
commit af3aacde19
2 changed files with 17 additions and 17 deletions

View File

@ -17,11 +17,15 @@ var fs = fsExtra;
var docShredder = require('./public/doc-shredder/doc-shredder'); var docShredder = require('./public/doc-shredder/doc-shredder');
var _shredOptions = { var _shredOptions = {
basePath: path.resolve('./public/docs'), examplesDir: path.resolve('./public/docs/_examples'),
examplesDir: "_examples", fragmentsDir: path.resolve('./public/docs/_fragments')
fragmentsDir: "_fragments"
}; };
//var _apiShredOptions = {
// basePath: path.resolve('../angular/modules/angular2'),
// examplesDir: "test"
//}
var _excludePatterns = ["**/node_modules/**", "**/typings/**"]; var _excludePatterns = ["**/node_modules/**", "**/typings/**"];
var _excludeMatchers = _excludePatterns.map(function(excludePattern){ var _excludeMatchers = _excludePatterns.map(function(excludePattern){
@ -226,7 +230,7 @@ function getChangedExamplesForCommit(commit, relativePath) {
} }
function shredWatch(shredOptions, postShredAction) { function shredWatch(shredOptions, postShredAction) {
var pattern = path.join(shredOptions.basePath, shredOptions.examplesDir, "**/*.*"); var pattern = path.join(shredOptions.examplesDir, "**/*.*");
watch([pattern], function (event, done) { watch([pattern], function (event, done) {
console.log('Event type: ' + event.event); // added, changed, or deleted console.log('Event type: ' + event.event); // added, changed, or deleted
console.log('Event path: ' + event.path); // The path of the modified file console.log('Event path: ' + event.path); // The path of the modified file

View File

@ -22,18 +22,16 @@ var shred = function(shredOptions) {
var shredSingleDir = function(shredOptions, filePath) { var shredSingleDir = function(shredOptions, filePath) {
shredOptions = resolveShredOptions(shredOptions); shredOptions = resolveShredOptions(shredOptions);
var root = path.resolve(shredOptions.basePath, shredOptions.examplesDir);
var fileDir = path.dirname(filePath); var fileDir = path.dirname(filePath);
var relativePath = path.relative(root, fileDir); var relativePath = path.relative(shredOptions.examplesDir, fileDir);
var examplesDir = path.join(shredOptions.examplesDir, relativePath); var examplesDir = path.join(shredOptions.examplesDir, relativePath);
var fragmentsDir = path.join(shredOptions.fragmentsDir, relativePath); var fragmentsDir = path.join(shredOptions.fragmentsDir, relativePath);
var options = { var options = {
basePath: shredOptions.basePath,
includeSubdirs: false, includeSubdirs: false,
examplesDir: examplesDir, examplesDir: examplesDir,
fragmentsDir: fragmentsDir fragmentsDir: fragmentsDir
} }
var cleanPath = path.join(shredOptions.basePath, fragmentsDir, '*.*') var cleanPath = path.join(fragmentsDir, '*.*')
return delPromise([ cleanPath, '!**/*.ovr.*']).then(function(paths) { return delPromise([ cleanPath, '!**/*.ovr.*']).then(function(paths) {
// console.log('Deleted files/folders:\n', paths.join('\n')); // console.log('Deleted files/folders:\n', paths.join('\n'));
return shred(options); return shred(options);
@ -74,7 +72,7 @@ function createShredPackage(shredOptions) {
// default configs - may be overriden // default configs - may be overriden
.config(function(readFilesProcessor) { .config(function(readFilesProcessor) {
// Specify the base path used when resolving relative paths to source and output files // Specify the base path used when resolving relative paths to source and output files
readFilesProcessor.basePath = options.basePath; readFilesProcessor.basePath = "/";
// Specify collections of source files that should contain the documentation to extract // Specify collections of source files that should contain the documentation to extract
var extns = ['*.js', '*.html', '*.ts', '*.css', '*.json' ]; var extns = ['*.js', '*.html', '*.ts', '*.css', '*.json' ];
@ -120,7 +118,7 @@ var createShredMapPackage = function(mapOptions) {
// default configs - may be overriden // default configs - may be overriden
.config(function(readFilesProcessor) { .config(function(readFilesProcessor) {
// Specify the base path used when resolving relative paths to source and output files // Specify the base path used when resolving relative paths to source and output files
readFilesProcessor.basePath = options.basePath; readFilesProcessor.basePath = '/'; // options.basePath;
// Specify collections of source files that should contain the documentation to extract // Specify collections of source files that should contain the documentation to extract
var extns = ['*.jade' ]; var extns = ['*.jade' ];
@ -184,11 +182,10 @@ var createShredMapPackage = function(mapOptions) {
function resolveShredOptions(shredOptions) { function resolveShredOptions(shredOptions) {
return _.defaults({}, shredOptions, { return _.defaults({}, shredOptions, {
basePath: path.resolve('.'),
// read files from any subdir under here // read files from any subdir under here
examplesDir: "docs/_examples", examplesDir: path.resolve("./docs/_examples"),
// shredded files get copied here with same subdir structure. // shredded files get copied here with same subdir structure.
fragmentsDir: "docs/_fragments", fragmentsDir: path.resolve("./docs/_fragments"),
// whether to include subdirectories when shredding. // whether to include subdirectories when shredding.
includeSubdirs: true includeSubdirs: true
}); });
@ -196,11 +193,10 @@ function resolveShredOptions(shredOptions) {
function resolveMapOptions(mapOptions) { function resolveMapOptions(mapOptions) {
return _.defaults({}, mapOptions, { return _.defaults({}, mapOptions, {
basePath: path.resolve('.'),
// read files from any subdir under here // read files from any subdir under here
jadeDir: "docs", jadeDir: path.resolve("./docs"),
fragmentsDir: "docs/_fragments", fragmentsDir: path.resolve("./docs/_fragments"),
examplesDir: "docs/_examples", examplesDir: path.resolve("./docs/_examples"),
// whether to include subdirectories when shredding. // whether to include subdirectories when shredding.
includeSubdirs: true includeSubdirs: true
}); });