From 8d896db809f8cf0b5480e2a54a0f485c9cbb5580 Mon Sep 17 00:00:00 2001 From: Jeff Williams Date: Thu, 5 Feb 2015 08:25:24 -0800 Subject: [PATCH] process `implements` tags before `augments` tags (#906) --- lib/jsdoc/augment.js | 2 +- test/fixtures/augmentall.js | 27 +++++++++++++++++++++++++++ test/jasmine-jsdoc.js | 7 ++++--- test/specs/jsdoc/augment.js | 15 +++++++++++++-- 4 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 test/fixtures/augmentall.js diff --git a/lib/jsdoc/augment.js b/lib/jsdoc/augment.js index 08307ea6..cc5fe9d5 100644 --- a/lib/jsdoc/augment.js +++ b/lib/jsdoc/augment.js @@ -513,7 +513,7 @@ exports.addImplemented = function(doclets) { * @return {void} */ exports.augmentAll = function(doclets) { - exports.addInherited(doclets); exports.addMixedIn(doclets); exports.addImplemented(doclets); + exports.addInherited(doclets); }; diff --git a/test/fixtures/augmentall.js b/test/fixtures/augmentall.js new file mode 100644 index 00000000..8cfd17b4 --- /dev/null +++ b/test/fixtures/augmentall.js @@ -0,0 +1,27 @@ +/** + * Parent interface. + * @interface + */ +function Connection() {} + +/** + * Open the connection. + */ +Connection.prototype.open = function() {}; + +/** + * Child class. + * @class + * @implements {Connection} + */ +function Socket() {} + +/** @inheritdoc */ +Socket.prototype.open = function() {}; + +/** + * Extension of child class. + * @class + * @extends {Socket} + */ +function EncryptedSocket() {} diff --git a/test/jasmine-jsdoc.js b/test/jasmine-jsdoc.js index ecf0a6ac..68d0f5db 100644 --- a/test/jasmine-jsdoc.js +++ b/test/jasmine-jsdoc.js @@ -142,7 +142,7 @@ jasmine.asyncSpecDone = function() { jasmine.asyncSpecWait.done = true; }; -jasmine.getDocSetFromFile = function(filename, parser, validate) { +jasmine.getDocSetFromFile = function(filename, parser, validate, augment) { var doclets; var validationResult; @@ -154,8 +154,9 @@ jasmine.getDocSetFromFile = function(filename, parser, validate) { doclets = testParser.parse('javascript:' + sourceCode); jsdoc.borrow.indexAll(doclets); - jsdoc.augment.addInherited(doclets); - jsdoc.augment.addImplemented(doclets); + if (augment !== false) { + jsdoc.augment.augmentAll(doclets); + } // test assume borrows have not yet been resolved // require('jsdoc/borrow').resolveBorrows(doclets); diff --git a/test/specs/jsdoc/augment.js b/test/specs/jsdoc/augment.js index 0ffeeb1f..55b4ec15 100644 --- a/test/specs/jsdoc/augment.js +++ b/test/specs/jsdoc/augment.js @@ -39,7 +39,7 @@ describe('jsdoc/augment', function() { describe('augmentAll', function() { it('should call all other methods that the module exports', function() { - var docSet = jasmine.getDocSetFromFile('test/fixtures/mixintag2.js'); + var docSet = jasmine.getDocSetFromFile('test/fixtures/mixintag2.js', null, null, false); var methodNames = Object.keys(augment).filter(function(name) { return name !== 'augmentAll'; }); @@ -48,11 +48,22 @@ describe('jsdoc/augment', function() { spyOn(augment, name); }); - augment.augmentAll(docSet); + augment.augmentAll(docSet.doclets); methodNames.forEach(function(name) { expect(augment[name]).toHaveBeenCalled(); }); }); + + it('should process @implements tags before @augments tags', function() { + var docSet = jasmine.getDocSetFromFile('test/fixtures/augmentall.js', null, null, false); + var open; + + augment.augmentAll(docSet.doclets); + + open = docSet.getByLongname('EncryptedSocket#open')[0]; + + expect(open.description).toBe('Open the connection.'); + }); }); });