mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
fix(jsdoc): use the correct scope for exported classes with constructors
Previously, if a module exported an ES2015 class, and the class had a constructor, the generated docs claimed that the class was in the `inner` scope. But `inner` means that the class is _not_ exported. This issue occurred because we generate separate doclets for the class declaration and constructor. When we merged the two, we incorrectly gave priority to properties in the constructor's doclet, rather than the class declaration's doclet. The constructor's doclet uses the `inner` scope; the class declaration's doclet uses the `static` scope.
This commit is contained in:
parent
f11bc773ee
commit
c9270a4fb5
@ -319,7 +319,7 @@ function makeConstructorFinisher(parser) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
combined = combineDoclets(eventDoclet, parentDoclet);
|
combined = combineDoclets(parentDoclet, eventDoclet);
|
||||||
combined.longname = parentDoclet.longname;
|
combined.longname = parentDoclet.longname;
|
||||||
if (parentDoclet.memberof) {
|
if (parentDoclet.memberof) {
|
||||||
combined.memberof = parentDoclet.memberof;
|
combined.memberof = parentDoclet.memberof;
|
||||||
|
|||||||
13
packages/jsdoc/test/fixtures/aliasexports.js
vendored
Normal file
13
packages/jsdoc/test/fixtures/aliasexports.js
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/** @module foo */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bar class.
|
||||||
|
*
|
||||||
|
* @alias module:foo.Bar
|
||||||
|
*/
|
||||||
|
class Bar {
|
||||||
|
/** Create a Bar. */
|
||||||
|
constructor() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.Bar = Bar;
|
||||||
@ -106,4 +106,14 @@ describe('aliases', () => {
|
|||||||
expect(method).toBeArrayOfSize(1);
|
expect(method).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('class with constructor exported from module', () => {
|
||||||
|
it('When an exported class with a constructor has an alias, the exported class has the correct scope.', () => {
|
||||||
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/aliasexports.js');
|
||||||
|
const klass = docSet.getByLongname('module:foo.Bar').filter(d => !d.undocumented);
|
||||||
|
|
||||||
|
expect(klass).toBeArrayOfSize(1);
|
||||||
|
expect(klass[0].scope).toBe('static');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user