grigoryvp
grigoryvp

Reputation: 42463

Why JSDoc duplicates JSON records if I put ES6 "export" in front of an identifier?

Given following source code:

/** Comment */
const foo = {};

Generating JSON JSDoc documentation for it:

npx jsdoc -X foo.js

produces expected result:

[{
  "description": "Comment",
  "name": "foo",
  "kind": "constant",
  "scope": "global"
}]

But if i place export ES6 keyword in front of the identifier:

/** Comment */
export const foo = {};

the resulting JSON will contain two records for "foo"! One as previous and one "undocumented". Any hints why such strange behavior? Any way to fix it?

[{
  "description": "Comment",
  "name": "foo",
  "kind": "constant",
  "scope": "global"
},
{
  "undocumented": true,
  "name": "foo",
  "kind": "constant",
  "scope": "global"
}]

Upvotes: 3

Views: 220

Answers (1)

Marco
Marco

Reputation: 2324

According to the JSDoc documentation, you need to include a @module tag when using module exports.

You could do:

/** @module some/module */

/** Comment */
const foo = {};

or simply

/** @module */

/** Comment */
const foo = {};

Upvotes: 1

Related Questions