[![view on npm](http://img.shields.io/npm/v/jsdoc-api.svg)](https://www.npmjs.org/package/jsdoc-api)
[![npm module downloads](http://img.shields.io/npm/dt/jsdoc-api.svg)](https://www.npmjs.org/package/jsdoc-api)
[![Build Status](https://travis-ci.org/jsdoc2md/jsdoc-api.svg?branch=master)](https://travis-ci.org/jsdoc2md/jsdoc-api)
[![Coverage Status](https://coveralls.io/repos/jsdoc2md/jsdoc-api/badge.svg?branch=master&service=github)](https://coveralls.io/github/jsdoc2md/jsdoc-api?branch=master)
[![Dependency Status](https://badgen.net/david/dep/jsdoc2md/jsdoc-api)](https://david-dm.org/jsdoc2md/jsdoc-api)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)
[![Join the chat at https://gitter.im/jsdoc2md/jsdoc2md](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jsdoc2md/jsdoc2md?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
# jsdoc-api
A programmatic interface for [jsdoc3](https://github.com/jsdoc3/jsdoc) with a few features:
- Sync and async (Promise) interfaces on the two main jsdoc operations ('explain' and 'render documentation').
- Input (source code) can supplied as a string or set of file names/globs.
- Optional caching, dramatically speeding up future invocations with the same input.
## Synopsis
```js
> 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' ] } ]
```
# API Reference
* [jsdoc-api](#module_jsdoc-api)
* _static_
* [.cache](#module_jsdoc-api.cache) : [cache-point
](https://github.com/75lb/cache-point)
* [.explainSync([options])](#module_jsdoc-api.explainSync) ⇒ Array.<object>
* [.explain([options])](#module_jsdoc-api.explain) ⇒ Promise
* [.renderSync([options])](#module_jsdoc-api.renderSync)
* _inner_
* [~JsdocOptions](#module_jsdoc-api..JsdocOptions)
* [.files](#module_jsdoc-api..JsdocOptions+files) : string
\| Array.<string>
* [.source](#module_jsdoc-api..JsdocOptions+source) : string
* [.cache](#module_jsdoc-api..JsdocOptions+cache) : boolean
* [.access](#module_jsdoc-api..JsdocOptions+access) : string
* [.configure](#module_jsdoc-api..JsdocOptions+configure) : string
* [.destination](#module_jsdoc-api..JsdocOptions+destination) : string
* [.encoding](#module_jsdoc-api..JsdocOptions+encoding) : string
* [.private](#module_jsdoc-api..JsdocOptions+private) : boolean
* [.package](#module_jsdoc-api..JsdocOptions+package) : string
* [.pedantic](#module_jsdoc-api..JsdocOptions+pedantic) : boolean
* [.query](#module_jsdoc-api..JsdocOptions+query) : string
* [.recurse](#module_jsdoc-api..JsdocOptions+recurse) : boolean
* [.readme](#module_jsdoc-api..JsdocOptions+readme) : string
* [.template](#module_jsdoc-api..JsdocOptions+template) : string
* [.tutorials](#module_jsdoc-api..JsdocOptions+tutorials) : string
### jsdoc.cache : [cache-point
](https://github.com/75lb/cache-point)
The [cache-point](https://github.com/75lb/cache-point) instance used when `cache: true` is specified on `.explain()` or `.explainSync()`.
**Kind**: static property of [jsdoc-api
](#module_jsdoc-api)
### jsdoc.explainSync([options]) ⇒ Array.<object>
Returns jsdoc explain output.
**Kind**: static method of [jsdoc-api
](#module_jsdoc-api)
**Prerequisite**: Requires node v0.12 or above
| Param | Type |
| --- | --- |
| [options] | [JsdocOptions
](#module_jsdoc-api..JsdocOptions) |
### jsdoc.explain([options]) ⇒ Promise
Returns a promise for the jsdoc explain output.
**Kind**: static method of [jsdoc-api
](#module_jsdoc-api)
**Fulfil**: object[]
- jsdoc explain output
| Param | Type |
| --- | --- |
| [options] | [JsdocOptions
](#module_jsdoc-api..JsdocOptions) |
### jsdoc.renderSync([options])
Render jsdoc documentation.
**Kind**: static method of [jsdoc-api
](#module_jsdoc-api)
**Prerequisite**: Requires node v0.12 or above
| Param | Type |
| --- | --- |
| [options] | [JsdocOptions
](#module_jsdoc-api..JsdocOptions) |
**Example**
```js
jsdoc.renderSync({ files: 'lib/*', destination: 'api-docs' })
```
### jsdoc-api~JsdocOptions
The jsdoc options, common for all operations.
**Kind**: inner class of [jsdoc-api
](#module_jsdoc-api)
* [~JsdocOptions](#module_jsdoc-api..JsdocOptions)
* [.files](#module_jsdoc-api..JsdocOptions+files) : string
\| Array.<string>
* [.source](#module_jsdoc-api..JsdocOptions+source) : string
* [.cache](#module_jsdoc-api..JsdocOptions+cache) : boolean
* [.access](#module_jsdoc-api..JsdocOptions+access) : string
* [.configure](#module_jsdoc-api..JsdocOptions+configure) : string
* [.destination](#module_jsdoc-api..JsdocOptions+destination) : string
* [.encoding](#module_jsdoc-api..JsdocOptions+encoding) : string
* [.private](#module_jsdoc-api..JsdocOptions+private) : boolean
* [.package](#module_jsdoc-api..JsdocOptions+package) : string
* [.pedantic](#module_jsdoc-api..JsdocOptions+pedantic) : boolean
* [.query](#module_jsdoc-api..JsdocOptions+query) : string
* [.recurse](#module_jsdoc-api..JsdocOptions+recurse) : boolean
* [.readme](#module_jsdoc-api..JsdocOptions+readme) : string
* [.template](#module_jsdoc-api..JsdocOptions+template) : string
* [.tutorials](#module_jsdoc-api..JsdocOptions+tutorials) : string
#### options.files : string
\| Array.<string>
One or more filenames to process. Either this or `source` must be supplied.
**Kind**: instance property of [JsdocOptions
](#module_jsdoc-api..JsdocOptions)
#### options.source : string
A string containing source code to process. Either this or `files` must be supplied.
**Kind**: instance property of [JsdocOptions
](#module_jsdoc-api..JsdocOptions)
#### options.cache : boolean
Set to `true` to cache the output - future invocations with the same input will return immediately.
**Kind**: instance property of [JsdocOptions
](#module_jsdoc-api..JsdocOptions)
#### options.access : 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
](#module_jsdoc-api..JsdocOptions)
#### options.configure : string
The path to the configuration file. Default: path/to/jsdoc/conf.json.
**Kind**: instance property of [JsdocOptions
](#module_jsdoc-api..JsdocOptions)
#### options.destination : string
The path to the output folder. Use "console" to dump data to the console. Default: ./out/.
**Kind**: instance property of [JsdocOptions
](#module_jsdoc-api..JsdocOptions)
#### options.encoding : string
Assume this encoding when reading all source files. Default: utf8.
**Kind**: instance property of [JsdocOptions
](#module_jsdoc-api..JsdocOptions)
#### options.private : boolean
Display symbols marked with the @private tag. Equivalent to "--access all". Default: false.
**Kind**: instance property of [JsdocOptions
](#module_jsdoc-api..JsdocOptions)
#### options.package : string
The path to the project's package file. Default: path/to/sourcefiles/package.json
**Kind**: instance property of [JsdocOptions
](#module_jsdoc-api..JsdocOptions)
#### options.pedantic : boolean
Treat errors as fatal errors, and treat warnings as errors. Default: false.
**Kind**: instance property of [JsdocOptions
](#module_jsdoc-api..JsdocOptions)
#### options.query : string
A query string to parse and store in jsdoc.env.opts.query. Example: foo=bar&baz=true.
**Kind**: instance property of [JsdocOptions
](#module_jsdoc-api..JsdocOptions)
#### options.recurse : boolean
Recurse into subdirectories when scanning for source files and tutorials.
**Kind**: instance property of [JsdocOptions
](#module_jsdoc-api..JsdocOptions)
#### options.readme : string
The path to the project's README file. Default: path/to/sourcefiles/README.md.
**Kind**: instance property of [JsdocOptions
](#module_jsdoc-api..JsdocOptions)
#### options.template : string
The path to the template to use. Default: path/to/jsdoc/templates/default.
**Kind**: instance property of [JsdocOptions
](#module_jsdoc-api..JsdocOptions)
#### options.tutorials : string
Directory in which JSDoc should search for tutorials.
**Kind**: instance property of [JsdocOptions
](#module_jsdoc-api..JsdocOptions)
* * *
© 2015-19 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).