mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 21:24:09 +00:00
2f6c109901
Added support for short `{@link #member}` markup. This makes interlinking much cleaner and shorter; similar short-link support was available in previous versions of jsdoc.
50 lines
No EOL
1.1 KiB
JavaScript
50 lines
No EOL
1.1 KiB
JavaScript
/**
|
|
* Transform '{@link #x}' to '{@link longname#x x}' which saves lots of cumersome typing.
|
|
*
|
|
* This looks in @description, @classdesc and @see tags only.
|
|
*
|
|
* See https://github.com/jsdoc3/jsdoc/issues/483
|
|
*/
|
|
|
|
var path = require('path');
|
|
|
|
function expandLinks (text, parent) {
|
|
|
|
return text.replace(/\{\s*@link\s+([#.])([\w$.]+)\s*\}/g, function (m, mod, name) {
|
|
var expanded = "{@link " + parent + mod + name + " " + name + "}";
|
|
return expanded;
|
|
});
|
|
|
|
}
|
|
|
|
exports.handlers = {};
|
|
exports.handlers.newDoclet = function (e) {
|
|
|
|
var doclet = e.doclet;
|
|
var parent;
|
|
if (doclet.kind === 'class' || doclet.kind === 'interface')
|
|
{
|
|
parent = doclet.longname;
|
|
}
|
|
else
|
|
{
|
|
// member, method, property, etc.
|
|
parent = doclet.memberof;
|
|
}
|
|
|
|
['description', 'classdesc'].forEach(function (p) {
|
|
if (doclet[p])
|
|
{
|
|
doclet[p] = expandLinks(doclet[p], parent);
|
|
}
|
|
});
|
|
|
|
if (doclet.see && doclet.see.length)
|
|
{
|
|
for (var i = 0; i < doclet.see.length; i++)
|
|
{
|
|
doclet.see[i] = expandLinks(doclet.see[i], parent);
|
|
}
|
|
}
|
|
|
|
}; |