forked from jdalton/docdown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·34 lines (30 loc) · 895 Bytes
/
index.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
33
34
/*!
* docdown v0.1.0
* Copyright 2011-2015 John-David Dalton <http://allyoucanleet.com/>
* Available under MIT license <http://mths.be/mit>
*/
'use strict';
var _ = require('lodash'),
path = require('path'),
fs = require('fs'),
generator = require('./lib/generator.js');
/**
* Generates Markdown documentation based on JSDoc comments.
*
* @name docdown
* @param options The options to use to generate documentation.
* @returns {string} The generated Markdown code.
*/
function docdown(options) {
options = _.defaults(options || {}, {
'hash': 'default',
'lang': 'js',
'title': path.basename(options.path) + ' API documentation',
'toc': 'properties'
});
if (!options.path || !options.url) {
throw new Error('Path and/or URL must be specified');
}
return generator(fs.readFileSync(options.path, 'utf8'), options);
}
module.exports = docdown;