Merge pull request #156 from llaxsll/master

@partial Possibly this should be a core tag, but I think some time in the plugin incubator will be very useful, as a way to test it out and see how suitable it is for core. Thank you for contributing.
This commit is contained in:
Michael Mathews 2012-08-12 13:43:18 -07:00
commit dcafed5d0c

30
plugins/partial.js Normal file
View File

@ -0,0 +1,30 @@
/**
@overview Adds support for reusable partial jsdoc files.
@module plugins/partial
@author Ludo Antonov <ludo@hulu.com>
*/
var fs = require('fs');
var path = require('path');
exports.handlers = {
///
/// Include a partial jsdoc
/// @param e
/// @param e.filename
/// @param e.source
///
/// @example
/// @partial "partial_doc.jsdoc"
///
beforeParse: function(e) {
e.source = e.source.replace(/(@partial \".*\")+/g, function($) {
var pathArg = $.match(/\".*\"/)[0].replace(/"/g,'');
var fullPath = path.join(e.filename , '..', pathArg);
var partialData = fs.readFileSync(fullPath);
return partialData;
});
}
};