Closed GoogleCodeExporter closed 8 years ago
It may be obvious to you (and I) that myClass is a "class" but JsDoc Toolkit
can't tell if it's meant to be called
as simple function or if it's meant to called with the "new" keyword unless you
tell it so. Use the @class tag or
the @constructor tag.
(using the -a option)
/** @class */
function myClass() {
this.value = 'that';
// etc.
return this;
}
myClass.prototype.myMethod = function() {
// function body
}
Original comment by micmath
on 24 Feb 2009 at 6:11
Thanks Michael!
Had already tried that - but I can't remember if I used the -a option - will
check
when I'm back at work tomorrow.
Matt
Original comment by mcalth...@gmail.com
on 24 Feb 2009 at 9:11
The -a option just means "document (a)ll functions, even those that have no
doc-comments attached to
them." As you have no doc-comment for myClass.prototype.myMethod, you will need
to use the -a option to
get it to appear in your output. However, you may omit the -a if you provide a
comment, like so:
/** @class */
function myClass() {
this.value = 'that';
// etc.
return this;
}
/** This is just an example method. */
myClass.prototype.myMethod = function() {
// function body
}
Original comment by micmath
on 25 Feb 2009 at 9:32
Ok, I'm getting closer...
When I test this code in isolation, it works as expected:
/** @class */
function myClass() {
this.value = 'that';
// etc.
return this;
}
/** this is myMethod */
myClass.prototype.myMethod = function() {
// function body
}
However, when I test it as part of a much larger suite of code, I get a lot of
warning messages for the other files, and here are the messages I get for the
myClass
file:
>> WARNING: Trying to document myClass as a member of undocumented symbol
IPC.Dialog#.
>> WARNING: Trying to document myMethod as a member of undocumented symbol
myClass.
IPC.Dialog is a class that has been defined in another file.
So is the context somehow being messed up?
And if so, is there a way of resetting it?
many thanks,
Matt
Original comment by mcalth...@gmail.com
on 25 Feb 2009 at 9:47
Ah - finally found the solution:
/** @scope global */
/** @class */
function myClass() {
this.value = 'that';
// etc.
return this;
}
myClass.prototype.myMethod = function() {
// function body
}
I don't even need a comment above myMethod for it to be picked up.
Also: don't combine the two JSDoc comments into one - JSDoc won't pick up the
code.
Original comment by mcalth...@gmail.com
on 11 Mar 2009 at 3:57
oops - that first line of code should have read:
/** @scope _global_ */
(underscore before & after "global")
Matt
Original comment by mcalth...@gmail.com
on 12 Mar 2009 at 11:32
That's pretty clever, I never would have thought to do that actually!
Original comment by micmath
on 19 Mar 2009 at 9:58
It took lots of experimentation!
Original comment by mcalth...@gmail.com
on 19 Mar 2009 at 10:23
Original issue reported on code.google.com by
mcalth...@gmail.com
on 24 Feb 2009 at 5:10