Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit af3aacd

Browse files
committed
remove basePath from docShredder options. Not useful and confusing when examplesDir and fragmentsDir don't share a basePath ( as when used for api shredding)
1 parent 39f1959 commit af3aacd

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

gulpfile.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ var fs = fsExtra;
1717
var docShredder = require('./public/doc-shredder/doc-shredder');
1818

1919
var _shredOptions = {
20-
basePath: path.resolve('./public/docs'),
21-
examplesDir: "_examples",
22-
fragmentsDir: "_fragments"
20+
examplesDir: path.resolve('./public/docs/_examples'),
21+
fragmentsDir: path.resolve('./public/docs/_fragments')
2322
};
2423

24+
//var _apiShredOptions = {
25+
// basePath: path.resolve('../angular/modules/angular2'),
26+
// examplesDir: "test"
27+
//}
28+
2529
var _excludePatterns = ["**/node_modules/**", "**/typings/**"];
2630

2731
var _excludeMatchers = _excludePatterns.map(function(excludePattern){
@@ -226,7 +230,7 @@ function getChangedExamplesForCommit(commit, relativePath) {
226230
}
227231

228232
function shredWatch(shredOptions, postShredAction) {
229-
var pattern = path.join(shredOptions.basePath, shredOptions.examplesDir, "**/*.*");
233+
var pattern = path.join(shredOptions.examplesDir, "**/*.*");
230234
watch([pattern], function (event, done) {
231235
console.log('Event type: ' + event.event); // added, changed, or deleted
232236
console.log('Event path: ' + event.path); // The path of the modified file

public/doc-shredder/doc-shredder.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,16 @@ var shred = function(shredOptions) {
2222

2323
var shredSingleDir = function(shredOptions, filePath) {
2424
shredOptions = resolveShredOptions(shredOptions);
25-
var root = path.resolve(shredOptions.basePath, shredOptions.examplesDir);
2625
var fileDir = path.dirname(filePath);
27-
var relativePath = path.relative(root, fileDir);
26+
var relativePath = path.relative(shredOptions.examplesDir, fileDir);
2827
var examplesDir = path.join(shredOptions.examplesDir, relativePath);
2928
var fragmentsDir = path.join(shredOptions.fragmentsDir, relativePath);
3029
var options = {
31-
basePath: shredOptions.basePath,
3230
includeSubdirs: false,
3331
examplesDir: examplesDir,
3432
fragmentsDir: fragmentsDir
3533
}
36-
var cleanPath = path.join(shredOptions.basePath, fragmentsDir, '*.*')
34+
var cleanPath = path.join(fragmentsDir, '*.*')
3735
return delPromise([ cleanPath, '!**/*.ovr.*']).then(function(paths) {
3836
// console.log('Deleted files/folders:\n', paths.join('\n'));
3937
return shred(options);
@@ -74,7 +72,7 @@ function createShredPackage(shredOptions) {
7472
// default configs - may be overriden
7573
.config(function(readFilesProcessor) {
7674
// Specify the base path used when resolving relative paths to source and output files
77-
readFilesProcessor.basePath = options.basePath;
75+
readFilesProcessor.basePath = "/";
7876

7977
// Specify collections of source files that should contain the documentation to extract
8078
var extns = ['*.js', '*.html', '*.ts', '*.css', '*.json' ];
@@ -120,7 +118,7 @@ var createShredMapPackage = function(mapOptions) {
120118
// default configs - may be overriden
121119
.config(function(readFilesProcessor) {
122120
// Specify the base path used when resolving relative paths to source and output files
123-
readFilesProcessor.basePath = options.basePath;
121+
readFilesProcessor.basePath = '/'; // options.basePath;
124122

125123
// Specify collections of source files that should contain the documentation to extract
126124
var extns = ['*.jade' ];
@@ -184,23 +182,21 @@ var createShredMapPackage = function(mapOptions) {
184182

185183
function resolveShredOptions(shredOptions) {
186184
return _.defaults({}, shredOptions, {
187-
basePath: path.resolve('.'),
188185
// read files from any subdir under here
189-
examplesDir: "docs/_examples",
186+
examplesDir: path.resolve("./docs/_examples"),
190187
// shredded files get copied here with same subdir structure.
191-
fragmentsDir: "docs/_fragments",
188+
fragmentsDir: path.resolve("./docs/_fragments"),
192189
// whether to include subdirectories when shredding.
193190
includeSubdirs: true
194191
});
195192
}
196193

197194
function resolveMapOptions(mapOptions) {
198195
return _.defaults({}, mapOptions, {
199-
basePath: path.resolve('.'),
200196
// read files from any subdir under here
201-
jadeDir: "docs",
202-
fragmentsDir: "docs/_fragments",
203-
examplesDir: "docs/_examples",
197+
jadeDir: path.resolve("./docs"),
198+
fragmentsDir: path.resolve("./docs/_fragments"),
199+
examplesDir: path.resolve("./docs/_examples"),
204200
// whether to include subdirectories when shredding.
205201
includeSubdirs: true
206202
});

0 commit comments

Comments
 (0)