jsdoc/plugins/sourcetag.js
Jannon 393f6c9846 Beefier plugin documentation
Also updating the included plugins to export handlers in a "handlers" object.
2012-02-25 00:11:58 -08:00

42 lines
1.3 KiB
JavaScript

/**
@module plugins/sourcetag
@author Michael Mathews <micmath@gmail.com>
*/
exports.handlers = {
/**
Support @source tag. Expected value like:
{ "filename": "myfile.js", "lineno": 123 }
Modifies the corresponding meta values on the given doclet.
*/
newDoclet: function(e) {
var tags = e.doclet.tags,
tag,
value;
//console.log(e.doclet);
// any user-defined tags in this doclet?
if (typeof tags !== 'undefined') {
// only interested in the @source tags
tags = tags.filter(function($) {
return $.title === 'source';
});
if (tags.length) {
// take the first one
tag = tags[0];
try {
value = JSON.parse(tag.value);
}
catch(e) {
throw new Error('@source tag expects a valid JSON value, like { "filename": "myfile.js", "lineno": 123 }.');
}
!e.doclet.meta && (e.doclet.meta = {});
e.doclet.meta.filename = value.filename || '';
e.doclet.meta.lineno = value.lineno || '';
}
}
}
};