UNPKG

780 BJavaScriptView Raw
1/**
2 @overview Adds support for reusable partial jsdoc files.
3 @module plugins/partial
4 @author Ludo Antonov <ludo@hulu.com>
5 */
6'use strict';
7
8var fs = require('jsdoc/fs');
9var path = require('path');
10
11exports.handlers = {
12 /**
13 * Include a partial jsdoc
14 *
15 * @param e
16 * @param e.filename
17 * @param e.source
18 * @example
19 * @partial "partial_doc.jsdoc"
20 */
21 beforeParse: function(e) {
22 e.source = e.source.replace(/(@partial \".*\")+/g, function($) {
23 var pathArg = $.match(/\".*\"/)[0].replace(/"/g, '');
24 var fullPath = path.join(e.filename, '..', pathArg);
25
26 var partialData = fs.readFileSync(fullPath, global.env.opts.encoding);
27
28 return partialData;
29 });
30 }
31};