1

In particular, I'm interested in excluding any node_modules folders, but there are others that need to be excluded.

This is normally accomplished in a config file; e.g., a .jsdoc file, like so:

"source": {
    "include" : ["../projects"],
    "includePattern": ".*src\\\\.+\\.js(doc|x)?$",
    "excludePattern": "(node_modules|docs)"
}
kmiklas
  • 13,085
  • 22
  • 67
  • 103

1 Answers1

1

The best way that worked for me was to annotation my documentation with @public @private etc. and then passing the option --access: ['public', 'private'] to selectively include the pieces that I wanted.

As par the documentation

--access, -a  Include only comments with a given access level, 
              out of private, protected, public, undefined. By
              default, public, protected, and undefined access
              levels are included
[array] [choices: "public", "private", "protected", "undefined"]

You could write a script to programmatically generate the docs

documentation
    .build('src/index.js', { access: ["public"] })
    .then(documentation.formats.md)
    .then(markdown => {
      fs.writeFileSync('README.md'), markdown);
    })
    .catch(error => console.error(error));

EDITED:

Just to be clear, here is how to use the console command -

documentation build ./src/index.js --access private public protected -f html -o docs
Sohail
  • 4,506
  • 2
  • 38
  • 42
  • Did you test this? there shouldn't be a `:` after `--access` but even when I run it without I get `Invalid values: Argument: access, Given: "[public,", "private]", Choices: "public", "private", "protected", "undefined"` – eriese Feb 09 '19 at 19:10
  • @eriese I am not sure how you are running it, but you can surely pass the values as an array if you follow the second piece of code where I have written a script to generate the documentation. – Sohail Feb 10 '19 at 09:45
  • I was running `documentation build src/index.js --access ['public', 'private']` directly in the console, so that was my problem, and I guess I have to take that up with documentationJs directly. But I think that your answer would benefit from noting that it doesn't work in their command line so that those of us who come here with different use cases know that that's not the advice you're giving. – eriese Feb 10 '19 at 19:22
  • @eriese ofcourse it wont work because you are doing it wrong. Have you tried doing this `documentation build ./src/index.js --access private public protected -f html -o docs` – Sohail Feb 10 '19 at 23:02
  • That worked. Thank you! And thank you for making the edit. – eriese Feb 11 '19 at 06:18