diff --git a/about.json b/about.json index 708c6666..584391e0 100644 --- a/about.json +++ b/about.json @@ -1,6 +1,6 @@ { "app": { - "name": "jsdoc-toolkit-3", - "version": "0.0.0+2010-06-07-2143" + "name": "jsdoc-3", + "version": "0.0.0+2010-06-27-2042" } } diff --git a/build.xml b/build.xml index ed644753..f93d22c8 100644 --- a/build.xml +++ b/build.xml @@ -1,6 +1,6 @@ - + @@ -20,5 +20,18 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/build/build.properties b/build/build.properties index 51bbde74..2369ee6c 100644 --- a/build/build.properties +++ b/build/build.properties @@ -1,2 +1,2 @@ -app.name=jsdoc-toolkit-3 +app.name=jsdoc-3 app.version=0.0.0 diff --git a/main.js b/main.js index cce42ba4..5b59dbc7 100644 --- a/main.js +++ b/main.js @@ -1,5 +1,5 @@ /** - * @overview JSDoc Toolkit Version 3 + * @overview JSDoc 3 * @copyright 2010 (c) Michael Mathews * @license See LICENSE.md file included in this distribution. */ @@ -64,17 +64,20 @@ java.lang.System.exit(0); } - sourceFiles = jsdoc.src.getFilePaths(opts._); + if (opts._.length > 0) { + sourceFiles = jsdoc.src.getFilePaths(opts._); - jsdoc.parser.parseFiles(sourceFiles, opts.encoding); - - if (opts.validate) { - var jsonSchema = require('sitepen/jsonSchema'); - var jsdocSchema = require('jsdoc/schema').jsdocSchema; - var validation = jsonSchema.validate(jsdoc.parser.result.toObject(), jsdocSchema); - print('Validation: ' + validation.toSource()); + jsdoc.parser.parseFiles(sourceFiles, opts.encoding); + + if (opts.validate) { + var jsonSchema = require('sitepen/jsonSchema'); + var jsdocSchema = require('jsdoc/schema').jsdocSchema; + var validation = jsonSchema.validate(jsdoc.parser.result.toObject(), jsdocSchema); + print('Validation: ' + validation.toSource()); + } + + print( jsdoc.parser.result.toString(opts.destination) ); } - print( jsdoc.parser.result.toString(opts.destination) ); })(); //// \ No newline at end of file diff --git a/modules/common/fs.js b/modules/common/fs.js index 374803eb..f69146a7 100644 --- a/modules/common/fs.js +++ b/modules/common/fs.js @@ -70,7 +70,7 @@ exports.ls = function(dir, recurse, _allFiles, _path) { var files, file; - + if (typeof _path === 'undefined') { // initially _allFiles = []; _path = [dir]; @@ -90,7 +90,7 @@ if ((new File(_path.join(slash) + slash + file)).list()) { // it's a directory _path.push(file); - + if (_path.length - 1 < recurse) { exports.ls(_path.join(slash), recurse, _allFiles, _path); } diff --git a/modules/jsdoc/src.js b/modules/jsdoc/src.js index 8d0c41d3..6505a8f4 100644 --- a/modules/jsdoc/src.js +++ b/modules/jsdoc/src.js @@ -23,10 +23,10 @@ jsdoc.src = (typeof exports === 'undefined')? {} : exports; // like commonjs */ jsdoc.src.getFilePaths = function(searchPaths, depth) { var filePaths = []; - + searchPaths = searchPaths || []; depth = depth || 1; - + searchPaths.forEach(function($) { filePaths = filePaths.concat(fs.ls($, depth)); }); diff --git a/modules/jsdoc/test.js b/modules/jsdoc/test.js deleted file mode 100644 index edfd769e..00000000 --- a/modules/jsdoc/test.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - @overview - @author Michael Mathews - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - */ - -/** - Unit tests runner for JSDoc Toolkit. - @module jsdoc/test - */ -(function() { - - exports.runAll = function() { - load(BASEDIR + 'lib/jsunity.js'); - - testSuites = []; - load(BASEDIR + 'tests/opts.js'); - load(BASEDIR + 'tests/docset.js'); - load(BASEDIR + 'tests/tag_namespace.js'); - load(BASEDIR + 'tests/tag_constructor.js'); - load(BASEDIR + 'tests/tag_const.js'); - load(BASEDIR + 'tests/tag_enum.js'); - load(BASEDIR + 'tests/tag_param.js'); - load(BASEDIR + 'tests/tag_example.js'); - - jsUnity.attachAssertions(); - jsUnity.log = function (s) { print(s); }; - var results = jsUnity.run.apply(jsUnity, testSuites); - summarize(results); - } - - function summarize(results) { - var colorStart, - colorEnd = '\033[m'; - - print('------------------'); - print('Total: ' + results.total + ' tests'); - - if (results.failed === 0) { - colorStart = '\033[1;37;42m', // green - print(colorStart + 'ALL PASS' + colorEnd); - } - else { - colorStart = '\033[1;37;41m'; // red - print(colorStart + results.failed + 'FAILED' + colorEnd); - } - print(''); - } - -})(); \ No newline at end of file diff --git a/test/samples/src/dir1/three.js b/test/samples/src/dir1/three.js new file mode 100644 index 00000000..e69de29b diff --git a/test/samples/src/ignored.txt b/test/samples/src/ignored.txt new file mode 100644 index 00000000..e69de29b diff --git a/test/samples/src/one.js b/test/samples/src/one.js new file mode 100644 index 00000000..e69de29b diff --git a/test/samples/src/two.js b/test/samples/src/two.js new file mode 100644 index 00000000..e69de29b diff --git a/test/tests/02_jsdoc_src.js b/test/tests/02_jsdoc_src.js index 6f790b19..28033915 100644 --- a/test/tests/02_jsdoc_src.js +++ b/test/tests/02_jsdoc_src.js @@ -16,6 +16,47 @@ expect(jsdoc.src).to(respond_to, 'getFilePaths'); }); }); + + describe('The return value of jsdoc.src#getFilePaths when called with no arguments', function() { + it('should return an empty array', function() { + var returnedValue = jsdoc.src.getFilePaths(); + expect(returnedValue).to(be_an, Array); + expect(returnedValue).to(have_length, 0); + }); + }); + + describe('The return value of jsdoc.src#getFilePaths when called with an array with one src dir and no depth', function() { + it('should return an array of 2 file paths', function() { + var returnedValue = jsdoc.src.getFilePaths(['test/samples/src']); + expect(returnedValue).to(be_an, Array); + expect(returnedValue).to(have_length, 2); + }); + + it('should contain both js files and not the txt file', function() { + var returnedValue = jsdoc.src.getFilePaths(['test/samples/src']); + + expect( returnedValue.indexOf('test/samples/src/one.js') ).to(be_at_least, 0); + expect( returnedValue.indexOf('test/samples/src/two.js') ).to(be_at_least, 0); + expect( returnedValue.indexOf('test/samples/src/ignored.txt') ).to(be_less_than, 0); + }); + }); + + describe('The return value of jsdoc.src#getFilePaths when called with an array with one src dir and depth of 2', function() { + it('should return an array of 3 file paths', function() { + var returnedValue = jsdoc.src.getFilePaths(['test/samples/src'], 2); + expect(returnedValue).to(be_an, Array); + expect(returnedValue).to(have_length, 3); + }); + + it('should contain all three js files and not the txt file', function() { + var returnedValue = jsdoc.src.getFilePaths(['test/samples/src'], 2); + + expect( returnedValue.indexOf('test/samples/src/one.js') ).to(be_at_least, 0); + expect( returnedValue.indexOf('test/samples/src/two.js') ).to(be_at_least, 0); + expect( returnedValue.indexOf('test/samples/src/dir1/three.js') ).to(be_at_least, 0); + expect( returnedValue.indexOf('test/samples/src/ignored.txt') ).to(be_less_than, 0); + }); + }); }); })();