mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
correctly document constructors and instance properties of ES2015 classes (#1182)
This commit is contained in:
parent
67db938c0b
commit
0e4f1a9575
@ -359,6 +359,11 @@ Parser.prototype.astnodeToMemberof = function(node) {
|
||||
|
||||
result.memberof = doclet.longname + jsdoc.name.SCOPE.PUNC.INSTANCE;
|
||||
}
|
||||
else if (type === Syntax.MethodDefinition && node.kind === 'constructor') {
|
||||
doclet = this._getDocletById(node.enclosingScope.nodeId);
|
||||
|
||||
result.memberof = doclet.memberof + jsdoc.name.SCOPE.PUNC.INNER;
|
||||
}
|
||||
else {
|
||||
// check local references for aliases
|
||||
scope = node;
|
||||
|
||||
19
test/fixtures/moduleclasses.js
vendored
Normal file
19
test/fixtures/moduleclasses.js
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
/** @module foo */
|
||||
|
||||
/** Bar class. */
|
||||
class Bar {
|
||||
/** Construct a Bar. */
|
||||
constructor() {
|
||||
/** bar property */
|
||||
this.bar = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Baz class. */
|
||||
export class Baz {
|
||||
/** Construct a Baz. */
|
||||
constructor() {
|
||||
/** baz property */
|
||||
this.baz = 0;
|
||||
}
|
||||
}
|
||||
31
test/specs/documentation/moduleclasses.js
Normal file
31
test/specs/documentation/moduleclasses.js
Normal file
@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
describe('module classes', function() {
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/moduleclasses.js');
|
||||
var bar = docSet.getByLongname('module:foo~Bar')[0];
|
||||
var barBar = docSet.getByLongname('module:foo~Bar#bar')[0];
|
||||
var baz = docSet.getByLongname('module:foo.Baz')[0];
|
||||
var bazBaz = docSet.getByLongname('module:foo.Baz#baz')[0];
|
||||
|
||||
describe('inner classes', function() {
|
||||
it('should merge the constructor doclet with the class doclet', function() {
|
||||
expect(bar.description).toBe('Construct a Bar.');
|
||||
expect(bar.classdesc).toBe('Bar class.');
|
||||
});
|
||||
|
||||
it('should correctly mark the scope of instance properties', function() {
|
||||
expect(barBar.scope).toBe('instance');
|
||||
});
|
||||
});
|
||||
|
||||
describe('exported classes', function() {
|
||||
it('should merge the constructor doclet with the class doclet', function() {
|
||||
expect(baz.description).toBe('Construct a Baz.');
|
||||
expect(baz.classdesc).toBe('Baz class.');
|
||||
});
|
||||
|
||||
it('should correctly mark the scope of instance properties', function() {
|
||||
expect(bazBaz.scope).toBe('instance');
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user