What is jsdoc-api?
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.
What are jsdoc-api's main functionalities?
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);
Other packages similar to jsdoc-api
documentation
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.
esdoc
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.
typedoc
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.
jsdoc-api
Example
const jsdoc = require('jsdoc-api')
jsdoc.explainSync(files) ⇒ object
Returns jsdoc explain output
Kind: static method of jsdoc-api
Node: Requires version 0.12 and above
Param | Type | Description |
---|
files | string | Array.<string> | input file names |
explainSync.source(source) ⇒ Array.<object>
Returns jsdoc explain output, taking source code as input.
Kind: static method of explainSync
Node: Requires version 0.12 and above
Param | Type | Description |
---|
source | string | source code |
jsdoc.explain(files, [options]) ⇒ Promise
Kind: static method of jsdoc-api
Throws:
INVALID_FILES
- One or more files was not valid source code
Fulfil: object[]
- jsdoc explain output
Param | Type | Description |
---|
files | string | Array.<string> | input source files |
[options] | object | |
[options.configure] | | |
explain.source(source) ⇒ Promise
Kind: static method of explain
Fulfil: object[]
- jsdoc explain output
Param | Type | Description |
---|
source | string | input source code |
jsdoc.createExplainStream(files, [options]) ⇒ Readable
Kind: static method of jsdoc-api
Param | Type | Description |
---|
files | string | Array.<string> | input source files |
[options] | object | |
[options.configure] | | |
jsdoc.renderSync(files, [options])
Kind: static method of jsdoc-api
Param | Type | Description |
---|
files | string | Array.<string> | input source files |
[options] | object | options |
[options.destination] | | destination path |
renderSync.source(source, [options])
Kind: static method of renderSync
Param | Type | Description |
---|
source | string | the source code |
[options] | object | options |
[options.destination] | | destination path |
© 2015 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.