Martin Cup
Martin Cup

Reputation: 2582

JSDoc outputs same variable twice

JSDoc prints the list of all the members twice. And in these lists it prints every member also twice. Any idea what could cause this behaviour?

This is my code:

/** @module styles */

/**
 * Contains the general styles
 * @var _
 */

var _ = StyleSheet.create({});

This is my configuration file:

{
  "tags": {
    "allowUnknownTags": true,
    "dictionaries": ["jsdoc", "closure"]
  },
  "source": {
    "include": [ "./styles.js" ],
    "includePattern": ".+\\.js$",
    "excludePattern": ""
  },
  "plugins": [],
  "templates": {
    "cleverLinks": false,
    "monospaceLinks": false
  },
  "opts": {
    "destination": "./docs/",
    "encoding": "utf8"
  }
}

This is the command to generate the docs:

jsdoc . -c conf.json

This is the result:

enter image description here

Upvotes: 2

Views: 1047

Answers (3)

Marc Nicole
Marc Nicole

Reputation: 389

I had a similar issue. I was passing the source in the command line and in the config file.

{
  "source": {
    "include": [
      "src"
    ]
  }
}

jsdoc -c jsdoc.json ./src
I had to remove it from either the config or the command. I choose to remove it from the command
jsdoc -c jsdoc.json

Upvotes: 1

Russ Bain
Russ Bain

Reputation: 401

I had this problem on two separate occasions.(jsdoc 3.6.10 with docdash 1.2.0)

One time it was caused by having an empty comment in the file like this one.

/*
* 
* */

Removing the empty comment eliminated duplicate output.

Another time the duplicate output was caused by my "includes" array in jsdoc.json

This caused it:

"include": ["./src", "./src/lib"]

This did not:

"include": ["./src"]

Upvotes: 0

Martin Cup
Martin Cup

Reputation: 2582

I found the error. It happens because in the configuration I'm using:

"include": [ "./styles.js" ], 

AND

"includePattern": ".+\\.js$",

If I change include to an empty array it outputs everything once. I thought includePattern only filters everything that's included, but that's not the case. It matches the files again.

Upvotes: 4

Related Questions