kmiklas
kmiklas

Reputation: 13433

How to include and exclude directories for parsing with documentationjs

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)"
}

Upvotes: 1

Views: 1005

Answers (1)

Sohail
Sohail

Reputation: 4586

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

Upvotes: 1

Related Questions