Open
Description
Input code
/**
* @mixes Mixin
*/
class MyClass {
constructor() {
}
}
/**
* @mixin
*/
const Mixin = {
/**
* A field
*/
field: 'value'
};
Additional observations:
- From some debugging, I've traced the issue down to the fact that there are duplicate "doclets" for
MyClass
. One for the class itself, and one for the undocumentedconstructor
. The logic that adds the mixin fields adds the fields once for each instance. - Based on the above, one workaround for this is to use a simple function constructor (e.g.
function MyClass() {}
instead of the class declaration. - I played around with the code a bit, and changing
if (mixes)
withif (mixes && !doclet.undocumented)
here also fixes the issue, because the doclet instance for theconstructor
hasundocumented: true
in my case. I'm not sure if that would be a reasonable fix for this, though, because the duplication may still cause issues elsewhere and in other similar cases. - I actually also use
@hideconstructor
for theMyClass
equivalent, but that doesn't change the behavior and isn't necessary for reproducing this issue.
JSDoc configuration
Reproduces without any configuration.
JSDoc debug output
DEBUG: JSDoc 4.0.2 (Sun, 19 Feb 2023 23:01:18 GMT)
DEBUG: Environment info: {"env":{"conf":{"plugins":[],"recurseDepth":10,"source":{"includePattern":".+\\.js(doc|x)?$","excludePattern":"(^|\\/|\\\\)_"},"sourceType":"module","tags":{"allowUnknownTags":true,"dictionaries":["jsdoc","closure"]},"templates":{"monospaceLinks":false,"cleverLinks":false,"default":{"outputSourceFiles":true}}},"opts":{"_":["[redacted]test.js"],"debug":true,"destination":"docs","encoding":"utf8"}}}
DEBUG: Parsing source files: ["[redacted]/test.js"]
Parsing [redacted]/test.js ...
DEBUG: Finished parsing source files.
DEBUG: Adding inherited symbols, mixins, and interface implementations...
DEBUG: Adding borrowed doclets...
DEBUG: Post-processing complete.
Generating output files...
Finished running in 0.14 seconds.
Expected behavior
MyClass#field
should only be documented once.
Current behavior
MyClass#field
is documented twice.

Your environment
Software | Version |
---|---|
JSDoc | 4.0.2 |
Node.js | v14.21.3 |
npm | 6.14.18 |
Operating system | macOS 14.1 |
Metadata
Metadata
Assignees
Labels
No labels