diff --git a/tasks/config/docs.js b/tasks/config/docs.js index f2192a83b..cdc3fa8d9 100644 --- a/tasks/config/docs.js +++ b/tasks/config/docs.js @@ -5,7 +5,11 @@ /* Paths used for "serve-docs" and "build-docs" tasks */ module.exports = { base: '', + globs: { + eco: '**/*.html.eco' + }, paths: { + clean: '../docs/out/dist/', source: { config : 'src/theme.config', definitions : 'src/definitions/', @@ -14,6 +18,7 @@ module.exports = { }, output: { less : '../docs/out/src/', + metadata : '../docs/out/', packaged : '../docs/out/dist/', uncompressed : '../docs/out/dist/components/', compressed : '../docs/out/dist/components/', @@ -22,6 +27,5 @@ module.exports = { template: { eco: '../docs/server/documents/' }, - clean: '../docs/out/dist/' } }; diff --git a/tasks/config/project/install.js b/tasks/config/project/install.js index 8badaa481..7e7c68ffc 100644 --- a/tasks/config/project/install.js +++ b/tasks/config/project/install.js @@ -92,7 +92,6 @@ module.exports = { folder = pathArray[pathArray.length - 1], nextDirectory = path.join(directory, path.sep, '..') ; - console.log(folder, nextDirectory); if( folder == 'bower_components') { return { name: 'Bower', diff --git a/tasks/docs/build.js b/tasks/docs/build.js index 96eb40fec..1aa1f2ae8 100644 --- a/tasks/docs/build.js +++ b/tasks/docs/build.js @@ -76,10 +76,11 @@ module.exports = function(callback) { // metadata.result object. Note this assumes that the docs // repository is present and in proper directory location as // specified by docs.json. - gulp.src(config.paths.template.eco + '**/*.html.eco') + console.info('Building Metadata'); + gulp.src(config.paths.template.eco + globs.eco) .pipe(map(metadata.parser)) .on('end', function() { - fs.writeFile(output.less + '/metadata.json', JSON.stringify(metadata.result, null, 2)); + fs.writeFile(output.metadata + '/metadata.json', JSON.stringify(metadata.result, null, 2)); }); ; @@ -87,6 +88,7 @@ module.exports = function(callback) { Copy Source ---------------*/ + console.info('Copying LESS source'); // copy src/ to server gulp.src('src/**/*.*') .pipe(gulp.dest(output.less)) diff --git a/tasks/docs/metadata.js b/tasks/docs/metadata.js index ef3b5f3db..ec61c437e 100644 --- a/tasks/docs/metadata.js +++ b/tasks/docs/metadata.js @@ -1,3 +1,4 @@ + /******************************* Summarize Docs *******************************/ @@ -27,74 +28,81 @@ function startsWith(str, prefix) { * @param {function(?,File)} - callback provided by map-stream to * reply when done. */ -function parseFile(file, cb) { +function parser(file, callback) { + // file exit conditions + if(file.isNull()) { + return callback(null, file); // pass along + } - if (file.isNull()) - return cb(null, file); // pass along - if (file.isStream()) - return cb(new Error("Streaming not supported")); + if(file.isStream()) { + return callback(new Error('Streaming not supported')); + } try { var - /** @type {string} */ - text = String(file.contents.toString('utf8')), - lines = text.split('\n'); + /** @type {string} */ + text = String(file.contents.toString('utf8')), + lines = text.split('\n') + filename = file.path.substring(0, file.path.length - 4), + key = 'server/documents', + position = filename.indexOf(key) + ; - if (!lines) + // exit conditions + if(!lines) { return; + } + if(position < 0) { + return callback(null, file); + } - var filename = file.path; - filename = filename.substring(0, filename.length - 4); - var key = 'server/documents'; - var position = filename.indexOf(key); - if (position < 0) - return cb(null, file); filename = filename.substring(position + key.length + 1, filename.length); - //console.log('Parsing ' + filename); - - var n = lines.length, - active = false, - yaml = [], - line + var + lineCount = lines.length, + active = false, + yaml = [], + index, + meta, + line ; + for (index = 0; index < lineCount; index++) { - var line; - for (var i = 0; i < n; i++) { - line = lines[i]; + line = lines[index]; // Wait for metadata block to begin - if (!active) { - if (startsWith(line, '---')) + if(!active) { + if(startsWith(line, '---')) { active = true; + } continue; } - - // End of metadata block, stop parsing. - if (startsWith(line, '---')) + if(startsWith(line, '---')) { break; - + } yaml.push(line); } // Parse yaml. - var meta = YAML.parse(yaml.join('\n')); - meta.category = meta.type; - meta.filename = filename; - meta._title = meta.title; // preserve original, just in case - meta.title = meta.type + ': ' + meta.title; + meta = YAML.parse(yaml.join('\n')); + if(meta && meta.category !== 'Draft' && meta.title !== undefined) { + meta.category = meta.type; + meta.filename = filename; + meta.title = meta.title; + } + // Primary key will by filepath data[filename] = meta; - //console.log("Parsed " + filename + ": " + JSON.stringify(meta)); + } - } catch(e) { - console.log(e); + catch(error) { + console.log(error, filename); } - cb(null,file); + callback(null, file); } @@ -102,6 +110,6 @@ function parseFile(file, cb) { * Export function expected by map-stream. */ module.exports = { - result: data, - parser: parseFile + result : data, + parser : parser };