mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
This first part of the testing framework upgrade: - enhances the jsdoc script to allow switching to debug mode from the command line - uses Jasmine to run tests - adds flexibility to run tests from multiple root directories - does automatic test discovery, so test files can just be created, dropped in an appropriate folder, and run without having to explicity add it to the test runner - cleans up the test directory layout - incorporates env.rhino.js which should make it easier to test templates - is incomplete: this is just a savepoint. About 1/3 of the tests have been converted. The rest are still run through the old testrunner
34 lines
1005 B
JavaScript
34 lines
1005 B
JavaScript
exports.getDocSetFromFile = function(filename) {
|
|
var sourceCode = readFile(__dirname + '/' + filename),
|
|
testParser,
|
|
doclets;
|
|
|
|
testParser = new (require('jsdoc/src/parser')).Parser();
|
|
require('jsdoc/src/handlers').attachTo(testParser);
|
|
|
|
doclets = testParser.parse('javascript:' + sourceCode);
|
|
testhelpers.indexAll(doclets);
|
|
|
|
require('jsdoc/augment').addInherited(doclets);
|
|
|
|
// test assume borrows have not yet been resolved
|
|
// require('jsdoc/borrow').resolveBorrows(doclets);
|
|
|
|
return {
|
|
doclets: doclets,
|
|
getByLongname: function(longname) {
|
|
return doclets.filter(function(doclet) {
|
|
return (doclet.longname || doclet.name) === longname;
|
|
});
|
|
}
|
|
};
|
|
};
|
|
|
|
exports.indexAll = function(docs) {
|
|
var index = {};
|
|
docs.forEach(function(doc) {
|
|
if (!index.hasOwnProperty(doc.longname)){index[doc.longname] = [];}
|
|
index[doc.longname].push(doc);
|
|
});
|
|
docs.index = index;
|
|
}; |