forked from documentationjs/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarkdown.js
32 lines (31 loc) · 903 Bytes
/
markdown.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { remark } from 'remark';
import remarkGfm from 'remark-gfm';
import markdownAST from './markdown_ast.js';
/**
* Formats documentation as
* [Markdown](https://daringfireball.net/projects/markdown/).
*
* @param {Array<Object>} comments parsed comments
* @param {Object} args Options that can customize the output
* @name formats.markdown
* @returns {Promise<string>} a promise of the eventual value
* @public
* @example
* var documentation = require('documentation');
* var fs = require('fs');
*
* documentation.build(['index.js'])
* .then(documentation.formats.md)
* .then(output => {
* // output is a string of Markdown data
* fs.writeFileSync('./output.md', output);
* });
*/
export default function markdown(comments, args) {
if (!args) {
args = {};
}
return markdownAST(comments, args).then(ast =>
remark().use(remarkGfm).stringify(ast)
);
}