<commit_before># jsdoc-x

[![build-status](https://img.shields.io/travis/onury/jsdoc-x.svg?branch=master)](https://travis-ci.org/onury/jsdoc-x)
[![npm](http://img.shields.io/npm/v/jsdoc-x.svg)](https://www.npmjs.com/package/jsdoc-x)
[![release](https://img.shields.io/github/release/onury/jsdoc-x.svg)](https://github.com/onury/jsdoc-x)
[![license](http://img.shields.io/npm/l/jsdoc-x.svg)](https://github.com/onury/jsdoc-x/blob/master/LICENSE)
[![downloads](https://img.shields.io/npm/dt/jsdoc-x.svg)](https://www.npmjs.com/package/jsdoc-x)
[![dependencies](https://david-dm.org/onury/jsdoc-x.svg)](https://david-dm.org/onury/jsdoc-x)
[![maintained](https://img.shields.io/maintenance/yes/2019.svg)](https://github.com/onury/jsdoc-x/graphs/commit-activity)  

> © 2019, <NAME> ([@onury](https://github.com/onury)). MIT License.

Parser for outputting a Javascript object from documented code via JSDoc's explain (`-X`) command.  

**Install via NPM**:
```shell
npm i jsdoc-x
```

## Usage:

```js
var jsdocx = require('jsdoc-x');
```

Parse using Promises...
```js
jsdocx.parse('./src/**/*.js')
    .then(function (docs) {
        console.log(docs);
    })
    .catch(function (err) {
        console.log(err.stack);
    });
```

Or callback...
```js
var options = { files: './src/**/*.js', hierarchy: true };
jsdocx.parse(options, function (err, docs) {
    if (err) {
        console.log(err.stack);
        return;
    }
    console.log(docs);
});
```

See an **output example** [here](https://github.com/onury/jsdoc-x/blob/master/test/output/docs.json).

## `jsdocx.parse(options[, callback])`  

Executes the `jsdoc -X` command and parses the output into a Javascript object/array; with the specified options.  

<table>
    <tr>
        <td><b>Param</b></td>
        <td><b>Type</b></td>
        <td><b>Description</b></td>
    </tr>
    <tr>
        <td><b><code>options</code></b></td>
        <td><code>Object|Array|String</code></td>
        <td>Required. Either an options object or one or more source files to be processed. See details below.</td>
    </tr>
    <tr>
        <td><b><code>callback</code></b></td>
        <td><code>Function</code></td>
        <td>
            Callback function to be executed in the following signature: `function (err, array) { ... }`. Omit this callback to return a `Promise`. Default: <code>undefined</code>
        </td>
    </tr>
</table>

### `options`
`Object|Array|String` - Parse options.

<table>
    <tr>
        <td><b>Option</b></td>
        <td><b>Type</b></td>
        <td><b>Description</b></td>
    </tr>
    <tr>
        <td><b><code>files</code></b></td>
        <td><code>String|Array</code></td>
        <td>
            Required (if <code>source</code> is not set). One or more file/directory paths to be processed. This also accepts a <a href="https://github.com/isaacs/node-glob">Glob</a> string or array of globs. e.g. <code>./src/&#x2A;&#x2A;/&#x2A;.js</code> will produce an array of all <code>.js</code> files under </code>./src</code> directory and sub-directories. Default: <code>undefined</code>
        </td>
    </tr>
    <tr>
        <td><b><code>source</code></b></td>
        <td><code>String</code></td>
        <td>
            Required (if <code>files</code> is not set). Documented source code to be processed. If <code>files</code> is also set, this will be ignored. Default: <code>undefined</code>
        </td>
    </tr>
    <tr>
        <td><b><code>encoding</code><b></td>
        <td><code>String</code></td>
        <td>Encoding to be used when reading source files. Default: <code>"utf8"</code></td>
    </tr>
    <tr>
        <td><b><code>recurse</code><b></td>
        <td><code>Boolean</code></td>
        <td>
            Specifies whether to recurse into subdirectories when scanning for source files. Default: <code>false</code>
        </td>
    </tr>
    <tr>
        <td><b><code>pedantic</code></b></td>
        <td><code>Boolean</code></td><commit_msg>updates README to include `config` property<commit_after># jsdoc-x

[![build-status](https://img.shields.io/travis/onury/jsdoc-x.svg?branch=master)](https://travis-ci.org/onury/jsdoc-x)
[![npm](http://img.shields.io/npm/v/jsdoc-x.svg)](https://www.npmjs.com/package/jsdoc-x)
[![release](https://img.shields.io/github/release/onury/jsdoc-x.svg)](https://github.com/onury/jsdoc-x)
[![license](http://img.shields.io/npm/l/jsdoc-x.svg)](https://github.com/onury/jsdoc-x/blob/master/LICENSE)
[![downloads](https://img.shields.io/npm/dt/jsdoc-x.svg)](https://www.npmjs.com/package/jsdoc-x)
[![dependencies](https://david-dm.org/onury/jsdoc-x.svg)](https://david-dm.org/onury/jsdoc-x)
[![maintained](https://img.shields.io/maintenance/yes/2019.svg)](https://github.com/onury/jsdoc-x/graphs/commit-activity)  

> © 2019, <NAME> ([@onury](https://github.com/onury)). MIT License.

Parser for outputting a Javascript object from documented code via JSDoc's explain (`-X`) command.  

**Install via NPM**:
```shell
npm i jsdoc-x
```

## Usage:

```js
var jsdocx = require('jsdoc-x');
```

Parse using Promises...
```js
jsdocx.parse('./src/**/*.js')
    .then(function (docs) {
        console.log(docs);
    })
    .catch(function (err) {
        console.log(err.stack);
    });
```

Or callback...
```js
var options = { files: './src/**/*.js', hierarchy: true };
jsdocx.parse(options, function (err, docs) {
    if (err) {
        console.log(err.stack);
        return;
    }
    console.log(docs);
});
```

See an **output example** [here](https://github.com/onury/jsdoc-x/blob/master/test/output/docs.json).

## `jsdocx.parse(options[, callback])`  

Executes the `jsdoc -X` command and parses the output into a Javascript object/array; with the specified options.  

<table>
    <tr>
        <td><b>Param</b></td>
        <td><b>Type</b></td>
        <td><b>Description</b></td>
    </tr>
    <tr>
        <td><b><code>options</code></b></td>
        <td><code>Object|Array|String</code></td>
        <td>Required. Either an options object or one or more source files to be processed. See details below.</td>
    </tr>
    <tr>
        <td><b><code>callback</code></b></td>
        <td><code>Function</code></td>
        <td>
            Callback function to be executed in the following signature: `function (err, array) { ... }`. Omit this callback to return a `Promise`. Default: <code>undefined</code>
        </td>
    </tr>
</table>

### `options`
`Object|Array|String` - Parse options.

<table>
    <tr>
        <td><b>Option</b></td>
        <td><b>Type</b></td>
        <td><b>Description</b></td>
    </tr>
    <tr>
        <td><b><code>files</code></b></td>
        <td><code>String|Array</code></td>
        <td>
            Required (if <code>source</code> is not set). One or more file/directory paths to be processed. This also accepts a <a href="https://github.com/isaacs/node-glob">Glob</a> string or array of globs. e.g. <code>./src/&#x2A;&#x2A;/&#x2A;.js</code> will produce an array of all <code>.js</code> files under </code>./src</code> directory and sub-directories. Default: <code>undefined</code>
        </td>
    </tr>
    <tr>
        <td><b><code>source</code></b></td>
        <td><code>String</code></td>
        <td>
            Required (if <code>files</code> is not set). Documented source code to be processed. If <code>files</code> is also set, this will be ignored. Default: <code>undefined</code>
        </td>
    </tr>
    <tr>
        <td><b><code>config</code></b></td>
        <td><code>Object</code></td>
        <td>
            Pass in all options as a single object. Overrides all other options. Allows passing custom config options to jsdoc. Default:  <code>{}</code>
        </td>
    </tr>
    <tr>
        <td><b><code>encoding</code><b></td>
        <td><code>String</code></td>
        <td>Encoding to be used when reading source files. Default: <code>"utf8"</code></td>
    </tr>
    <tr>
        <td><b><code>recurse</code><b></td>
        <td><code>Boolean</code></td>
        <td>
            Specifies whether to recurse into subdirectories when scanning for source files. Default: <code>false</code>
        </td>
    </tr>
    <tr>
        <td><b><code>pedantic</code></b></td>
        <td><code>Boolean</code></td>
{'fraction_non_alphanumeric': 0.21101251975203597, 'fraction_numerical': 0.002917223775373769, 'mean_word_length': 2.8793022159358794, 'pattern_counts': {'":': 0, '<': 321, '<?xml version=': 0, '>': 323, 'https://': 30, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4163276', 'n_tokens_mistral': 2996, 'n_tokens_neox': 2892, 'n_words': 575}