UNPKG

1.07 kBJavaScriptView Raw
1const path = require('path');
2const mergeConfig = require('../merge_config');
3
4/**
5 * Formats documentation as HTML.
6 *
7 * @param {Array<Comment>} comments parsed comments
8 * @param {Object} config Options that can customize the output
9 * @param {string} [config.theme='default_theme'] Name of a module used for an HTML theme.
10 * @returns {Promise<Array<Object>>} Promise with results
11 * @name formats.html
12 * @public
13 * @example
14 * var documentation = require('documentation');
15 * var streamArray = require('stream-array');
16 * var vfs = require('vinyl-fs');
17 *
18 * documentation.build(['index.js'])
19 * .then(documentation.formats.html)
20 * .then(output => {
21 * streamArray(output).pipe(vfs.dest('./output-directory'));
22 * });
23 */
24function html(comments, config) {
25 if (!config) {
26 config = {};
27 }
28 return mergeConfig(config).then(config => {
29 let themePath = '../default_theme/';
30 if (config.theme) {
31 themePath = path.resolve(process.cwd(), config.theme);
32 }
33 return require(themePath)(comments, config);
34 });
35}
36
37module.exports = html;