views:

97

answers:

1

Or do they and it's just not in the source? I'd really to get something that will stop js-doc-toolkit from freaking out each time it parses jQuery. It also means I can't properly document any code using jQuery as a dependency without at least putting some boilerplate js-doc blocks, which fail to properly document jQuery's structure. Is there a common solution I'm not aware of? I have tried googling, btw.

+2  A: 

I'll take a shot in the dark here since I can't speak for the jQuery team of why I wouldn't use JSDoc. JSDoc, at least the last time I checked, didn't have any clean way to support method overloading (or parameter shifting...whatever name you want to give it here) and jQuery uses this all over the place. Let's take a simple common example with .animate():

.animate({ height: 5 })
.animate({ height: 5 }, 100)
.animate({ height: 5 }, 100, "linear")
.animate({ height: 5 }, 100, "linear", func)
.animate({ height: 5 }, 100, func)
.animate({ height: 5 }, func)
.animate({ height: 5 }, { duration: 100, queue: false })
.animate({ height: 5 }, { duration: 100, easing: "linear" })
.animate({ height: 5 }, { duration: 100, easing: "linear", complete: func })

All of these are valid, since parameter types are checked and shifted as needed to support as any overload scenarios as possible...this just confuses the hell out of JSDoc, there's no clean way to add these optional parameters to the documentation. Please correct me if this has changed, but last I looked (and probably the last time the team took a look) this was still the case.

Another potential consideration is how some methods are generated when jQuery runs, for example (one of many) almost all then event handler shortcuts are generated in a loop, similar behavior for other methods...how would you document these? JSDoc generation just really doesn't work well here.

Nick Craver
I think the inability to document parameters to be totally correct isn't the biggest concern. I'm more concerned why objects and methods themselves can't at least be documented, so that JSDoc at least knows they exist and where to reference to. And one potential benefit of generating docs for a jQuery project is to have an easier time upgrading it from big changes to jQuery source. Is there a better doc generator out there? I've heard of Docco...
hlfcoding
@hlfcoding - I'm not sure if there's a better alternative, honestly I live in Visual Studio most of the time, and there's a provided `-vsdos.js` that is uses...some the Microsoft guys or community generate: http://stackoverflow.com/questions/2323366/jquery-1-4-2-vsdoc The editor depends on that documentation to tell you what the parameters are, if they're inaccurate all the time (and several methods are generated on the fly...how do you document them in source?) then they're not very useful.
Nick Craver