Socket
Socket
Sign inDemoInstall

jsdoc-to-markdown

Package Overview
Dependencies
82
Maintainers
1
Versions
119
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0-alpha.20 to 2.0.0-alpha.21

19

docs/API.md

@@ -10,3 +10,3 @@ <a name="module_jsdoc-to-markdown"></a>

* [jsdoc-to-markdown](#module_jsdoc-to-markdown)
* [JsdocToMarkdown](#exp_module_jsdoc-to-markdown--JsdocToMarkdown) ⇐ <code>JsdocToMarkdownCore</code> ⏏
* [JsdocToMarkdown](#exp_module_jsdoc-to-markdown--JsdocToMarkdown) ⏏
* _async_

@@ -27,5 +27,4 @@ * [.render([options])](#module_jsdoc-to-markdown--JsdocToMarkdown+render) ⇒ <code>Promise</code>

## JsdocToMarkdown ⇐ <code>JsdocToMarkdownCore</code> ⏏
## JsdocToMarkdown ⏏
**Kind**: Exported class
**Extends:** <code>JsdocToMarkdownCore</code>

@@ -158,2 +157,3 @@ -

* [.source](#JsdocOptions+source) : <code>string</code>
* [.data](#JsdocOptions+data) : <code>Array.&lt;object&gt;</code>
* [.configure](#JsdocOptions+configure) : <code>string</code>

@@ -177,3 +177,3 @@ * [.html](#JsdocOptions+html) : <code>boolean</code>

## options.files : <code>string</code> &#124; <code>Array.&lt;string&gt;</code>
One or more filenames to process. Either this or `source` must be supplied.
One or more filenames to process. Accepts globs (e.g. `*.js`). Either `files`, `source` or `data` must be supplied.

@@ -187,3 +187,3 @@ **Kind**: instance property of <code>[JsdocOptions](#JsdocOptions)</code>

## options.source : <code>string</code>
A string containing source code to process. Either this or `source` must be supplied.
A string containing source code to process. Either `files`, `source` or `data` must be supplied.

@@ -194,2 +194,11 @@ **Kind**: instance property of <code>[JsdocOptions](#JsdocOptions)</code>

<a name="JsdocOptions+data"></a>
## options.data : <code>Array.&lt;object&gt;</code>
Raw template data to use. Useful when you already have template data, obtained from `.getTemplateData`. Either `files`, `source` or `data` must be supplied.
**Kind**: instance property of <code>[JsdocOptions](#JsdocOptions)</code>
-
<a name="JsdocOptions+configure"></a>

@@ -196,0 +205,0 @@

@@ -16,2 +16,4 @@ 'use strict';

this.data = options.data;
this.configure = options.configure;

@@ -18,0 +20,0 @@

'use strict';
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var stats = require('jsdoc2md-stats');
var jsdocApi = require('jsdoc-api');
var dmd = require('dmd');
var os = require('os');
var UsageStats = require('app-usage-stats');
var DmdOptions = require('./dmd-options');
var JsdocOptions = require('./jsdoc-options');
var JsdocToMarkdownCore = function () {
function JsdocToMarkdownCore() {
_classCallCheck(this, JsdocToMarkdownCore);
var JsdocToMarkdown = function () {
function JsdocToMarkdown() {
_classCallCheck(this, JsdocToMarkdown);
}
_createClass(JsdocToMarkdownCore, [{
_createClass(JsdocToMarkdown, [{
key: 'render',

@@ -101,146 +95,7 @@ value: function render(options) {

return JsdocToMarkdownCore;
return JsdocToMarkdown;
}();
var JsdocToMarkdown = function (_JsdocToMarkdownCore) {
_inherits(JsdocToMarkdown, _JsdocToMarkdownCore);
module.exports = JsdocToMarkdown;
function JsdocToMarkdown() {
_classCallCheck(this, JsdocToMarkdown);
var _this = _possibleConstructorReturn(this, (JsdocToMarkdown.__proto__ || Object.getPrototypeOf(JsdocToMarkdown)).call(this));
_this._usage = new UsageStats('UA-70853320-3', {
name: 'jsdoc2md',
version: require('../../package').version,
sendInterval: 1000 * 60 * 60 * 24,
metricMap: {
invocation: 1,
source: 2,
configure: 3,
html: 4,
template: 5,
'heading-depth': 6,
'example-lang': 7,
plugin: 8,
helper: 9,
partial: 10,
'name-format': 11,
'no-gfm': 12,
separators: 13,
'module-index-format': 14,
'global-index-format': 15,
'param-list-format': 16,
'property-list-format': 17,
'member-index-format': 18,
private: 19,
cache: 20
},
dimensionMap: {
interface: 4,
exception: 5
}
});
_this._usage.loadSync();
_this._interface = 'api';
_this._sendOptions = { timeout: 2000 };
process.on('exit', function () {
return _this._usage.saveSync();
});
return _this;
}
_createClass(JsdocToMarkdown, [{
key: '_hit',
value: function _hit(method, options, exception) {
var metrics = Object.assign({ invocation: 1 }, options);
for (var key in metrics) {
metrics[key] = 1;
}
var dimensions = { name: method.name, interface: this._interface };
if (exception) dimensions.exception = exception;
this._sendOptions.send = options.send;
return this._usage.hit(dimensions, metrics, this._sendOptions);
}
}, {
key: '_stats',
value: function _stats(method, options) {
var _this2 = this;
options = options || {};
if (options['no-usage-stats']) this._usage.disable();
return method.call(JsdocToMarkdownCore.prototype, options).then(function (output) {
return _this2._hit(method, options).then(function () {
return output;
}).catch(function () {
return output;
});
}).catch(function (err) {
return _this2._hit(method, options, err.toString()).then(function () {
throw err;
}).catch(function () {
throw err;
});
});
}
}, {
key: '_statsSync',
value: function _statsSync(method, options) {
options = options || {};
if (options['no-usage-stats']) this._usage.disable();
try {
var output = method.call(JsdocToMarkdownCore.prototype, options);
this._hit(method, options);
return output;
} catch (err) {
this._hit(method, options, err.toString());
throw err;
}
}
}, {
key: 'render',
value: function render(options) {
return this._stats(_get(JsdocToMarkdown.prototype.__proto__ || Object.getPrototypeOf(JsdocToMarkdown.prototype), 'render', this), options);
}
}, {
key: 'renderSync',
value: function renderSync(options) {
return this._statsSync(_get(JsdocToMarkdown.prototype.__proto__ || Object.getPrototypeOf(JsdocToMarkdown.prototype), 'renderSync', this), options);
}
}, {
key: 'getTemplateData',
value: function getTemplateData(options) {
return this._stats(_get(JsdocToMarkdown.prototype.__proto__ || Object.getPrototypeOf(JsdocToMarkdown.prototype), 'getTemplateData', this), options);
}
}, {
key: 'getTemplateDataSync',
value: function getTemplateDataSync(options) {
return this._statsSync(_get(JsdocToMarkdown.prototype.__proto__ || Object.getPrototypeOf(JsdocToMarkdown.prototype), 'getTemplateDataSync', this), options);
}
}, {
key: 'getJsdocData',
value: function getJsdocData(options) {
return this._stats(_get(JsdocToMarkdown.prototype.__proto__ || Object.getPrototypeOf(JsdocToMarkdown.prototype), 'getJsdocData', this), options);
}
}, {
key: 'getJsdocDataSync',
value: function getJsdocDataSync(options) {
return this._statsSync(_get(JsdocToMarkdown.prototype.__proto__ || Object.getPrototypeOf(JsdocToMarkdown.prototype), 'getJsdocDataSync', this), options);
}
}, {
key: 'clear',
value: function clear() {
return this._stats(_get(JsdocToMarkdown.prototype.__proto__ || Object.getPrototypeOf(JsdocToMarkdown.prototype), 'clear', this));
}
}, {
key: 'getNamepaths',
value: function getNamepaths(options) {
return this._stats(_get(JsdocToMarkdown.prototype.__proto__ || Object.getPrototypeOf(JsdocToMarkdown.prototype), 'getNamepaths', this), options);
}
}]);
return JsdocToMarkdown;
}(JsdocToMarkdownCore);
module.exports = new JsdocToMarkdown();
module.exports = new (stats(JsdocToMarkdown, require('../../package').version))();
{
"name": "jsdoc-to-markdown",
"author": "Lloyd Brookes",
"version": "2.0.0-alpha.20",
"description": "jsdoc-annotated source in, markdown API docs out.",
"version": "2.0.0-alpha.21",
"description": "Generates markdown API documentation from jsdoc annotated source code",
"repository": "https://github.com/jsdoc2md/jsdoc-to-markdown",

@@ -28,3 +28,2 @@ "main": "main",

"dependencies": {
"app-usage-stats": "^0.3.0",
"array-back": "^1.0.3",

@@ -38,2 +37,3 @@ "command-line-tool": "^0.6.3",

"jsdoc-parse": "^2.0.5-0",
"jsdoc2md-stats": "^0.1.0",
"walk-back": "^2.0.1"

@@ -40,0 +40,0 @@ },

@@ -10,3 +10,3 @@ [![view on npm](http://img.shields.io/npm/v/jsdoc-to-markdown.svg)](https://www.npmjs.org/package/jsdoc-to-markdown)

# jsdoc-to-markdown
Generates markdown documentation from [jsdoc](http://usejsdoc.org) annotated source code. Useful for injecting API docs into project README files.
Generates markdown API documentation from [jsdoc](http://usejsdoc.org) annotated source code. Useful for injecting API docs into project README files.

@@ -13,0 +13,0 @@ ## Synopsis

@@ -16,3 +16,3 @@ 'use strict'

/**
* One or more filenames to process. Either this or `source` must be supplied.
* One or more filenames to process. Accepts globs (e.g. `*.js`). Either `files`, `source` or `data` must be supplied.
* @type {string|string[]}

@@ -23,3 +23,3 @@ */

/**
* A string containing source code to process. Either this or `source` must be supplied.
* A string containing source code to process. Either `files`, `source` or `data` must be supplied.
* @type {string}

@@ -30,2 +30,8 @@ */

/**
* Raw template data to use. Useful when you already have template data, obtained from `.getTemplateData`. Either `files`, `source` or `data` must be supplied.
* @type {object[]}
*/
this.data = options.data
/**
* The path to the configuration file. Default: path/to/jsdoc/conf.json.

@@ -32,0 +38,0 @@ * @type {string}

'use strict'
const stats = require('jsdoc2md-stats')
const jsdocApi = require('jsdoc-api')
const dmd = require('dmd')
const os = require('os')
const UsageStats = require('app-usage-stats')
const DmdOptions = require('./dmd-options')

@@ -15,159 +15,7 @@ const JsdocOptions = require('./jsdoc-options')

class JsdocToMarkdownCore {
render (options) {
options = options || {}
const dmdOptions = new DmdOptions(options)
if (options.data) {
return dmd.async(options.data, dmdOptions)
} else {
return this.getTemplateData(options)
.then(templateData => dmd.async(templateData, dmdOptions))
}
}
renderSync (options) {
options = options || {}
const dmdOptions = new DmdOptions(options)
if (options.data) {
return dmd(options.data, dmdOptions)
} else {
return dmd(this.getTemplateDataSync(options), dmdOptions)
}
}
getTemplateData (options) {
options = options || {}
const jsdocParse = require('jsdoc-parse')
return this.getJsdocData(options)
.then(jsdocParse)
}
getTemplateDataSync (options) {
options = options || {}
const jsdocParse = require('jsdoc-parse')
const jsdocData = this.getJsdocDataSync(options)
return jsdocParse(jsdocData, options)
}
getJsdocData (options) {
const jsdocOptions = new JsdocOptions(options)
return jsdocApi.explain(jsdocOptions)
}
getJsdocDataSync (options) {
const jsdocOptions = new JsdocOptions(options)
return jsdocApi.explainSync(jsdocOptions)
}
clear () {
return jsdocApi.cache.clear().then(() => dmd.cache.clear())
}
getNamepaths (options) {
return this.getTemplateData(options)
.then(data => {
const namepaths = {}
const kinds = [
'module', 'class', 'constructor', 'mixin', 'member',
'namespace', 'constant', 'function', 'event', 'typedef', 'external'
]
kinds.forEach(kind => {
namepaths[kind] = data
.filter(identifier => {
return identifier.kind === kind
})
.map(identifier => identifier.longname)
})
return namepaths
})
}
}
/**
* @alias module:jsdoc-to-markdown
* @extends JsdocToMarkdownCore
* @typicalname jsdoc2md
*/
class JsdocToMarkdown extends JsdocToMarkdownCore {
constructor () {
super()
this._usage = new UsageStats('UA-70853320-3', {
name: 'jsdoc2md',
version: require('../../package').version,
sendInterval: 1000 * 60 * 60 * 24, // 24 hours
metricMap: {
invocation: 1,
source: 2,
configure: 3,
html: 4,
template: 5,
'heading-depth': 6,
'example-lang': 7,
plugin: 8,
helper: 9,
partial: 10,
'name-format': 11,
'no-gfm': 12,
separators: 13,
'module-index-format': 14,
'global-index-format': 15,
'param-list-format': 16,
'property-list-format': 17,
'member-index-format': 18,
private: 19,
cache: 20
},
dimensionMap: {
interface: 4,
exception: 5
}
})
this._usage.loadSync()
this._interface = 'api'
this._sendOptions = { timeout: 2000 }
process.on('exit', () => this._usage.saveSync())
}
_hit (method, options, exception) {
const metrics = Object.assign({ invocation: 1 }, options)
for (const key in metrics) {
metrics[key] = 1
}
const dimensions = { name: method.name, interface: this._interface }
if (exception) dimensions.exception = exception
this._sendOptions.send = options.send
return this._usage.hit(dimensions, metrics, this._sendOptions)
}
_stats (method, options) {
options = options || {}
if (options['no-usage-stats']) this._usage.disable()
return method.call(JsdocToMarkdownCore.prototype, options)
.then(output => {
return this._hit(method, options)
.then(() => output)
.catch(() => output)
})
.catch(err => {
return this._hit(method, options, err.toString())
.then(() => { throw err })
.catch(() => { throw err })
})
}
_statsSync (method, options) {
options = options || {}
if (options['no-usage-stats']) this._usage.disable()
try {
const output = method.call(JsdocToMarkdownCore.prototype, options)
this._hit(method, options)
return output
} catch (err) {
this._hit(method, options, err.toString())
throw err
}
}
class JsdocToMarkdown {
/**

@@ -187,3 +35,10 @@ * Returns markdown documentation from jsdoc-annoted source code.

render (options) {
return this._stats(super.render, options)
options = options || {}
const dmdOptions = new DmdOptions(options)
if (options.data) {
return dmd.async(options.data, dmdOptions)
} else {
return this.getTemplateData(options)
.then(templateData => dmd.async(templateData, dmdOptions))
}
}

@@ -202,3 +57,9 @@

renderSync (options) {
return this._statsSync(super.renderSync, options)
options = options || {}
const dmdOptions = new DmdOptions(options)
if (options.data) {
return dmd(options.data, dmdOptions)
} else {
return dmd(this.getTemplateDataSync(options), dmdOptions)
}
}

@@ -215,3 +76,6 @@

getTemplateData (options) {
return this._stats(super.getTemplateData, options)
options = options || {}
const jsdocParse = require('jsdoc-parse')
return this.getJsdocData(options)
.then(jsdocParse)
}

@@ -227,3 +91,6 @@

getTemplateDataSync (options) {
return this._statsSync(super.getTemplateDataSync, options)
options = options || {}
const jsdocParse = require('jsdoc-parse')
const jsdocData = this.getJsdocDataSync(options)
return jsdocParse(jsdocData, options)
}

@@ -240,3 +107,4 @@

getJsdocData (options) {
return this._stats(super.getJsdocData, options)
const jsdocOptions = new JsdocOptions(options)
return jsdocApi.explain(jsdocOptions)
}

@@ -252,3 +120,4 @@

getJsdocDataSync (options) {
return this._statsSync(super.getJsdocDataSync, options)
const jsdocOptions = new JsdocOptions(options)
return jsdocApi.explainSync(jsdocOptions)
}

@@ -262,10 +131,27 @@

clear () {
return this._stats(super.clear)
return jsdocApi.cache.clear().then(() => dmd.cache.clear())
}
getNamepaths (options) {
return this._stats(super.getNamepaths, options)
return this.getTemplateData(options)
.then(data => {
const namepaths = {}
const kinds = [
'module', 'class', 'constructor', 'mixin', 'member',
'namespace', 'constant', 'function', 'event', 'typedef', 'external'
]
kinds.forEach(kind => {
namepaths[kind] = data
.filter(identifier => {
return identifier.kind === kind
})
.map(identifier => identifier.longname)
})
return namepaths
})
}
}
module.exports = new JsdocToMarkdown()
module.exports = JsdocToMarkdown
module.exports = new (stats(JsdocToMarkdown, require('../../package').version))()
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc