Open GoogleCodeExporter opened 8 years ago
I tooled around a bit, and not quite by dumb luck I landed upon a spot that let
me make a quick-fix to get what I wanted above inside of
JSDOC.Parser.addSymbol(symbol) at line 19.
The gist of my fix is to normalize a match replacement's prototypes to "#" and
remove the following dot. Currently it can match if you use "#" instead of
".prototype" in an @exports declaration, but the dot left behind prevents JsDoc
Toolkit from finding a documented symbol afterwards (ex: test.testf ->
App.Test#.testf).
replacement = JSDOC.Parser.rename[n].replace(/\.prototype(?:\.|$)/g, "#");
if (/#$/.test(replacement)) {
n += ".";
}
The non-capturing group part should ensure anything only starting with
prototype doesn't get mistakenly replaced. All the following calls to
symbol.alias.replace(*) use the variable "replacement".
This allows my previous example to be documented without any warnings and with
what appears to be correct output. It also allows the following, if you happen
to have such interesting code:
/**
* @namespace
*/
var App = {};
(function ()
{
/**
* @class
*/
App.Test = function ()
{
};
/**
* @exports test as App.Test.prototype.Bar
*/
var test =
/**
* @namespace
*/
App.Test.prototype.Bar = {};
/**
* This is a function on a namespace called "Bar" that only exists on instances of App.Test. It will show up as App.Test#Bar.testf in the documentation.
*/
test.testf = function ()
{
};
}());
Original comment by mcbain....@gmail.com
on 6 Jan 2012 at 2:04
'All the following calls to ...' -> 'The following calls to
symbol.name.replace(*) and symbol.alias.replace(*) use the variable
"replacement".'
Original comment by mcbain....@gmail.com
on 6 Jan 2012 at 2:07
Forgot to add that I declared the variable "replacement" in the fixed code
mentioned above here:
if (JSDOC.Parser.rename) {
var replacement;
which is only a few lines up from the fix itself.
Original comment by mcbain....@gmail.com
on 25 Jan 2012 at 1:03
Original issue reported on code.google.com by
mcbain....@gmail.com
on 6 Jan 2012 at 12:35