Merge pull request #421 from ErnstHaagsman/processingcomplete-event

Plugins: Created processingComplete event
This commit is contained in:
Jeff Williams 2013-06-02 16:45:01 -07:00
commit 0f79895be2
4 changed files with 16 additions and 1 deletions

View File

@ -237,6 +237,8 @@ function main() {
jsdoc.augment.addInherited(docs);
jsdoc.borrow.resolveBorrows(docs);
app.jsdoc.parser.fireProcessingComplete({doclets: docs});
if (env.opts.explain) {
dump(docs);
process.exit(0);

View File

@ -97,6 +97,10 @@ exports.Parser.prototype.parse = function(sourceFiles, encoding) {
return this._resultBuffer;
};
exports.Parser.prototype.fireProcessingComplete = function(doclets) {
this.emit('processingComplete', doclets);
};
/**
* @returns {Array<Doclet>} The accumulated results of any calls to parse.
*/

View File

@ -19,7 +19,8 @@ var events = conf.include || [
'symbolFound',
'newDoclet',
'fileComplete',
'parseComplete'
'parseComplete',
'processingComplete'
];
// Don't dump the excluded parser events
if (conf.exclude) {

View File

@ -77,6 +77,14 @@ describe("jsdoc/src/parser", function() {
expect(spy).toHaveBeenCalled();
expect(spy.mostRecentCall.args[0].sourcefiles).toEqual(["[[string0]]"]);
});
it("should fire processingComplete when fireProcessingComplete is called", function() {
var spy = jasmine.createSpy(),
doclets = {doclets: ['a','b']};
parser.on('processingComplete', spy).fireProcessingComplete(doclets);
expect(spy).toHaveBeenCalled();
expect(spy.mostRecentCall.args[0]).toEqual(doclets);
});
it("should be able to parse its own source file", function() {
var fs = require('jsdoc/fs'),