Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
The jsdoc-api npm package provides a programmatic interface to JSDoc, allowing you to generate documentation from JavaScript source code comments. It can be used to parse JSDoc comments and generate JSON output, making it easier to integrate JSDoc functionality into build processes or other tools.
Generate Documentation
This feature allows you to generate documentation from JavaScript files. The `renderSync` method processes the specified files and generates the documentation.
const jsdoc = require('jsdoc-api');
jsdoc.renderSync({
files: 'path/to/your/file.js'
});
Parse JSDoc Comments
This feature allows you to parse JSDoc comments from a source string. The `explainSync` method returns a JSON representation of the parsed comments.
const jsdoc = require('jsdoc-api');
const docs = jsdoc.explainSync({
source: '/**
* A description of the function.
* @param {string} name - The name of the person.
* @returns {string} A greeting message.
*/
function greet(name) {
return `Hello, ${name}!`;
}'
});
console.log(docs);
Configure JSDoc Options
This feature allows you to use a configuration file to customize the JSDoc generation process. The `configure` option specifies the path to a JSDoc configuration file.
const jsdoc = require('jsdoc-api');
const docs = jsdoc.explainSync({
files: 'path/to/your/file.js',
configure: 'path/to/jsdoc.conf.json'
});
console.log(docs);
The `documentation` package is another tool for generating documentation from JavaScript comments. It offers a command-line interface and programmatic API, similar to jsdoc-api. It supports ES6+ syntax and can output documentation in various formats, including HTML and Markdown.
The `esdoc` package is designed specifically for ES6+ JavaScript. It provides a comprehensive documentation generation tool with support for various plugins and themes. Compared to jsdoc-api, esdoc offers more modern syntax support and additional customization options.
The `typedoc` package is a documentation generator for TypeScript projects. It generates documentation based on TypeScript type annotations and comments. While jsdoc-api focuses on JavaScript, typedoc is tailored for TypeScript, providing better integration with TypeScript's type system.
A programmatic interface for jsdoc3 with a few features:
> const jsdoc = require('jsdoc-api')
> jsdoc.explainSync({ source: '/** example doclet */ \n var example = true' })
[ { comment: '/** example doclet *∕',
meta:
{ range: [ 28, 42 ],
filename: 'nkrf18zlymohia4i29a0zkyt84obt9.js',
lineno: 2,
path: '/var/folders/74/tqh7thm11tq72d7sjty9qvdh0000gn/T',
code:
{ id: 'astnode100000002',
name: 'example',
type: 'Literal',
value: true } },
description: 'example doclet',
name: 'example',
longname: 'example',
kind: 'member',
scope: 'global' },
{ kind: 'package',
longname: 'package:undefined',
files: [ '/var/folders/74/tqh7thm11tq72d7sjty9qvdh0000gn/T/nkrf18zlymohia4i29a0zkyt84obt9.js' ] } ]
cache-point
Array.<object>
Promise
string
| Array.<string>
string
boolean
string
string
string
string
boolean
string
boolean
string
boolean
string
string
string
cache-point
The cache-point instance used when cache: true
is specified on .explain()
or .explainSync()
.
Kind: static property of jsdoc-api
Array.<object>
Returns jsdoc explain output.
Kind: static method of jsdoc-api
Prerequisite: Requires node v0.12 or above
Param | Type |
---|---|
[options] | JsdocOptions |
Promise
Returns a promise for the jsdoc explain output.
Kind: static method of jsdoc-api
Fulfil: object[]
- jsdoc explain output
Param | Type |
---|---|
[options] | JsdocOptions |
Render jsdoc documentation.
Kind: static method of jsdoc-api
Prerequisite: Requires node v0.12 or above
Param | Type |
---|---|
[options] | JsdocOptions |
Example
jsdoc.renderSync({ files: 'lib/*', destination: 'api-docs' })
The jsdoc options, common for all operations.
Kind: inner class of jsdoc-api
string
| Array.<string>
string
boolean
string
string
string
string
boolean
string
boolean
string
boolean
string
string
string
string
| Array.<string>
One or more filenames to process. Either this or source
must be supplied.
Kind: instance property of JsdocOptions
string
A string containing source code to process. Either this or source
must be supplied.
Kind: instance property of JsdocOptions
boolean
Set to true
to cache the output - future invocations with the same input will return immediately.
Kind: instance property of JsdocOptions
string
Only display symbols with the given access: "public", "protected", "private" or "undefined", or "all" for all access levels. Default: all except "private".
Kind: instance property of JsdocOptions
string
The path to the configuration file. Default: path/to/jsdoc/conf.json.
Kind: instance property of JsdocOptions
string
The path to the output folder. Use "console" to dump data to the console. Default: ./out/.
Kind: instance property of JsdocOptions
string
Assume this encoding when reading all source files. Default: utf8.
Kind: instance property of JsdocOptions
boolean
Display symbols marked with the @private tag. Equivalent to "--access all". Default: false.
Kind: instance property of JsdocOptions
string
The path to the project's package file. Default: path/to/sourcefiles/package.json
Kind: instance property of JsdocOptions
boolean
Treat errors as fatal errors, and treat warnings as errors. Default: false.
Kind: instance property of JsdocOptions
string
A query string to parse and store in jsdoc.env.opts.query. Example: foo=bar&baz=true.
Kind: instance property of JsdocOptions
boolean
Recurse into subdirectories when scanning for source files and tutorials.
Kind: instance property of JsdocOptions
string
The path to the project's README file. Default: path/to/sourcefiles/README.md.
Kind: instance property of JsdocOptions
string
The path to the template to use. Default: path/to/jsdoc/templates/default.
Kind: instance property of JsdocOptions
string
Directory in which JSDoc should search for tutorials.
Kind: instance property of JsdocOptions
© 2015-18 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.
FAQs
A programmatic interface for jsdoc
The npm package jsdoc-api receives a total of 165,431 weekly downloads. As such, jsdoc-api popularity was classified as popular.
We found that jsdoc-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.