diff --git a/lib/jsdoc/src/visitor.js b/lib/jsdoc/src/visitor.js index 39961b09..9f8fde59 100644 --- a/lib/jsdoc/src/visitor.js +++ b/lib/jsdoc/src/visitor.js @@ -312,6 +312,7 @@ function makeDefaultParamFinisher() { */ function makeConstructorFinisher(parser) { return function(e) { + var combined; var doclet = e.doclet; var parentDoclet; @@ -330,17 +331,15 @@ function makeConstructorFinisher(parser) { return; } - if (!parentDoclet.description && doclet.description) { - parentDoclet.description = doclet.description; - } - if ( (!parentDoclet.params || !parentDoclet.params.length) && doclet.params) { - parentDoclet.params = doclet.params.slice(0); - } - if (doclet.hideconstructor) { - parentDoclet.hideconstructor = doclet.hideconstructor; + combined = jsdoc.doclet.combine(doclet, parentDoclet); + combined.longname = parentDoclet.longname; + if (parentDoclet.memberof) { + combined.memberof = parentDoclet.memberof; } - doclet.undocumented = true; + parser.addResult(combined); + + parentDoclet.undocumented = doclet.undocumented = true; }; } diff --git a/test/fixtures/classtag2.js b/test/fixtures/classtag2.js index f2dd0f1f..9c45b335 100644 --- a/test/fixtures/classtag2.js +++ b/test/fixtures/classtag2.js @@ -6,6 +6,8 @@ class Subscription { * Describe the constructor here. * * @param {string} name - The name of the subscription. + * @example + * var subscription = new Subscription(); */ constructor(name) {} diff --git a/test/specs/documentation/anonymousclass.js b/test/specs/documentation/anonymousclass.js index f434112d..6ef9d622 100644 --- a/test/specs/documentation/anonymousclass.js +++ b/test/specs/documentation/anonymousclass.js @@ -2,7 +2,9 @@ describe('anonymous class', function() { var docSet = jasmine.getDocSetFromFile('test/fixtures/anonymousclass.js'); - var klass = docSet.getByLongname('module:test')[2]; + var klass = docSet.getByLongname('module:test').filter(function($) { + return !$.undocumented; + })[1]; var foo = docSet.getByLongname('module:test#foo')[0]; var klassTest = docSet.getByLongname('module:test#test')[0]; var klassStaticTest = docSet.getByLongname('module:test.staticTest')[0]; diff --git a/test/specs/documentation/exportdefaultclass.js b/test/specs/documentation/exportdefaultclass.js index 76546cd3..3802ca1a 100644 --- a/test/specs/documentation/exportdefaultclass.js +++ b/test/specs/documentation/exportdefaultclass.js @@ -2,7 +2,9 @@ describe('export default class', function() { var docSet = jasmine.getDocSetFromFile('test/fixtures/exportdefaultclass.js'); - var klass = docSet.getByLongname('module:test')[2]; + var klass = docSet.getByLongname('module:test').filter(function($) { + return !$.undocumented; + })[1]; it('should combine the classdesc and constructor description into a single doclet', function() { expect(klass.classdesc).toBe('Test class'); diff --git a/test/specs/documentation/moduleclasses.js b/test/specs/documentation/moduleclasses.js index 1d09bf6a..971d6be7 100644 --- a/test/specs/documentation/moduleclasses.js +++ b/test/specs/documentation/moduleclasses.js @@ -1,10 +1,14 @@ 'use strict'; +function filter($) { + return !$.undocumented; +} + describe('module classes', function() { var docSet = jasmine.getDocSetFromFile('test/fixtures/moduleclasses.js'); - var bar = docSet.getByLongname('module:foo~Bar')[0]; + var bar = docSet.getByLongname('module:foo~Bar').filter(filter)[0]; var barBar = docSet.getByLongname('module:foo~Bar#bar')[0]; - var baz = docSet.getByLongname('module:foo.Baz')[0]; + var baz = docSet.getByLongname('module:foo.Baz').filter(filter)[0]; var bazBaz = docSet.getByLongname('module:foo.Baz#baz')[0]; describe('inner classes', function() { diff --git a/test/specs/tags/classtag.js b/test/specs/tags/classtag.js index f7dda38d..474bea39 100644 --- a/test/specs/tags/classtag.js +++ b/test/specs/tags/classtag.js @@ -1,5 +1,9 @@ 'use strict'; +function filter($) { + return !$.undocumented; +} + describe('@class tag', function() { var docSet = jasmine.getDocSetFromFile('test/fixtures/classtag.js'); var ticker = docSet.getByLongname('Ticker')[0]; @@ -16,11 +20,12 @@ describe('@class tag', function() { describe('ES 2015 classes', function() { var docSet2 = jasmine.getDocSetFromFile('test/fixtures/classtag2.js'); - var subscription = docSet2.getByLongname('Subscription')[0]; + var subscription = docSet2.getByLongname('Subscription').filter(filter)[0]; var expire = docSet2.getByLongname('Subscription#expire')[0]; - var subscriber = docSet2.getByLongname('Subscriber')[0]; + var subscriber = docSet2.getByLongname('Subscriber').filter(filter)[0]; var hasCallback = docSet2.getByLongname('Subscriber#hasCallback')[0]; - var expiringSubscription = docSet2.getByLongname('subclasses.ExpiringSubscription')[0]; + var expiringSubscription = docSet2.getByLongname('subclasses.ExpiringSubscription') + .filter(filter)[0]; var invalidSubscriptionFoo = docSet2.getByLongname('subclasses.InvalidSubscription#foo')[0]; it('When a symbol is a class declaration, the doclet does not require the @class tag', function() { @@ -33,6 +38,8 @@ describe('@class tag', function() { expect(subscription.description).toBe('Describe the constructor here.'); expect(subscription.params.length).toBe(1); expect(subscription.params[0].name).toBe('name'); + expect(subscription.examples.length).toBe(1); + expect(subscription.examples[0]).toBe('var subscription = new Subscription();'); }); it('When a symbol is a class declaration, its members get the correct longname and memberof', function() { diff --git a/test/specs/tags/hideconstructortag.js b/test/specs/tags/hideconstructortag.js index d791c52a..800bd4c5 100644 --- a/test/specs/tags/hideconstructortag.js +++ b/test/specs/tags/hideconstructortag.js @@ -3,7 +3,9 @@ describe('@hideconstructor tag', function() { var docSet = jasmine.getDocSetFromFile('test/fixtures/hideconstructortag.js'); var toaster = docSet.getByLongname('Toaster')[0]; - var waffleIron = docSet.getByLongname('WaffleIron')[0]; + var waffleIron = docSet.getByLongname('WaffleIron').filter(function($) { + return !$.undocumented; + })[0]; it('should add a `hideconstructor` attribute to pre-ES2015 classes', function() { expect(toaster.hideconstructor).toBe(true); diff --git a/test/specs/tags/moduletag.js b/test/specs/tags/moduletag.js index fd83fb02..6355b792 100644 --- a/test/specs/tags/moduletag.js +++ b/test/specs/tags/moduletag.js @@ -1,5 +1,9 @@ 'use strict'; +function filter($) { + return !$.undocumented; +} + describe('@module tag', function() { describe("using 'this'", function() { var docSet = jasmine.getDocSetFromFile('test/fixtures/moduletag.js'); @@ -19,9 +23,7 @@ describe('@module tag', function() { describe('misc', function() { var docSet = jasmine.getDocSetFromFile('test/fixtures/moduletag2.js'); - var mixer = docSet.getByLongname('module:color/mixer').filter(function($) { - return !($.undocumented); - })[0]; + var mixer = docSet.getByLongname('module:color/mixer').filter(filter)[0]; var blend = docSet.getByLongname('module:color/mixer.blend')[0]; var darken = docSet.getByLongname('module:color/mixer.darken')[0]; @@ -163,7 +165,7 @@ describe('@module tag', function() { describe('that export a class', function() { var docSet = jasmine.getDocSetFromFile('test/fixtures/moduletag11.js'); - var foo = docSet.getByLongname('module:foo.Foo')[0]; + var foo = docSet.getByLongname('module:foo.Foo').filter(filter)[0]; var testMethod = docSet.getByLongname('module:foo.Foo#testMethod')[0]; it('should identify the correct scope for the exported class', function() {