Including a Package File
Package files contain information that can be useful for your project's documentation, such as the project's name and version number. JSDoc can automatically use information from your project's package.json
file when it generates documentation. For example, the default template shows the project's name and version number in the documentation.
There are two ways to incorporate a package.json
file into your documentation:
- In the source paths to your JavaScript files, include the path to a
package.json
file. JSDoc will use the firstpackage.json
file that it finds in your source paths. - Run JSDoc with the
-P/--package
command-line option, specifying the path to yourpackage.json
file. This option is available in JSDoc 3.3.0 and later.
The -P/--package
command-line option takes precedence over your source paths. If you use the -P/--package
command-line option, JSDoc will ignore any package.json
files in your source paths.
The package.json
file must use npm's package format.
Examples
Including a package file in your source paths
jsdoc path/to/js path/to/package/package.json
Using the -P/--package option
jsdoc --package path/to/package/package-docs.json path/to/js