UNPKG

860 BJavaScriptView Raw
1const remark = require('remark');
2const markdownAST = require('./markdown_ast');
3
4/**
5 * Formats documentation as
6 * [Markdown](http://daringfireball.net/projects/markdown/).
7 *
8 * @param {Array<Object>} comments parsed comments
9 * @param {Object} args Options that can customize the output
10 * @name formats.markdown
11 * @returns {Promise<string>} a promise of the eventual value
12 * @public
13 * @example
14 * var documentation = require('documentation');
15 * var fs = require('fs');
16 *
17 * documentation.build(['index.js'])
18 * .then(documentation.formats.md)
19 * .then(output => {
20 * // output is a string of Markdown data
21 * fs.writeFileSync('./output.md', output);
22 * });
23 */
24function markdown(comments, args) {
25 if (!args) {
26 args = {};
27 }
28 return markdownAST(comments, args).then(ast => remark().stringify(ast));
29}
30
31module.exports = markdown;