Hi,
> I have been happily using JSDoc to document my JavaScript "classes".
> Can I document a JavaScript object created with an object literal?
> Something like
>
> /**
> * @object
> *
> * This is my foo object.
> */
> var foo = {
> /**
> * The bar function property.
> */
> bar: function(){},
> /**
> * The barbar array property.
> */
> barbar: []
> };
>
Unfortunately, no, the current version of JSDoc doesn't document global
objects like this, although it does seem to be something that is asked
for quite often.
As was pointed out by Ian Peterson earlier today on this list, your
code can be slightly changed (without changing the functionality of it)
to allow it to be documented by JSDoc, as shown below:
var foo;
foo = new function(){
this.bar = function(){};
};
I'm not too crazy about the idea of users having to change their code to
adapt to the tool, but as I said, that's the current situation.
Regards,
Gabriel
|