mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Most of the existing author tags are grossly out of date at this point. The definitive reference for who has contributed what is available at https://github.com/jsdoc3/jsdoc/graphs/contributors.
54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
/**
|
|
* @module plugins/sourcetag
|
|
*/
|
|
'use strict';
|
|
|
|
var logger = require('jsdoc/util/logger');
|
|
|
|
exports.handlers = {
|
|
/**
|
|
* Support @source tag. Expected value like:
|
|
*
|
|
* { "filename": "myfile.js", "lineno": 123 }
|
|
*
|
|
* Modifies the corresponding meta values on the given doclet.
|
|
*
|
|
* WARNING: If you are using a JSDoc template that generates pretty-printed source files,
|
|
* such as JSDoc's default template, this plugin can cause JSDoc to crash. To fix this issue,
|
|
* update your template settings to disable pretty-printed source files.
|
|
*
|
|
* @source { "filename": "sourcetag.js", "lineno": 9 }
|
|
*/
|
|
newDoclet: function(e) {
|
|
var tags = e.doclet.tags;
|
|
var tag;
|
|
var value;
|
|
|
|
// 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 (ex) {
|
|
logger.error('@source tag expects a valid JSON value, like { "filename": "myfile.js", "lineno": 123 }.');
|
|
|
|
return;
|
|
}
|
|
|
|
e.doclet.meta = e.doclet.meta || {};
|
|
e.doclet.meta.filename = value.filename || '';
|
|
e.doclet.meta.lineno = value.lineno || '';
|
|
}
|
|
}
|
|
}
|
|
};
|