Tom MacWright 25152edeb9 style(prettier): Use prettier for code formatting (#710)
* style(prettier): Use prettier for code formatting

This saves us style issues. Also adds husky and lint-staged for pre-commit testing

Refs https://github.com/documentationjs/documentation/issues/709
2017-04-10 14:25:45 -04:00

35 lines
763 B
JavaScript

'use strict';
/* @flow */
var walk = require('../walk');
/**
* Formats documentation as a JSON string.
*
* @param comments parsed comments
* @name formats.json
* @public
* @example
* var documentation = require('documentation');
* var fs = require('fs');
*
* documentation.build(['index.js'])
* .then(documentation.formats.json)
* .then(output => {
* // output is a string of JSON data
* fs.writeFileSync('./output.json', output);
* });
*/
function json(comments /*: Array<Comment>*/) /*: Promise<string>*/ {
walk(comments, comment => {
delete comment.errors;
if (comment.context) {
delete comment.context.sortKey;
}
});
return Promise.resolve(JSON.stringify(comments, null, 2));
}
module.exports = json;