home :: computers :: programming :: javascript :: documentation standard

Is there a JavaScript Library Documentation Standard?

Is there a JavaScript documentation standard? I’ve been working on a test framework for JavaScript and I’d like to integrate documentation so that others can use it.

If there isn’t a documentation standard, I can see three possible options that I’d like to suggest:

Use XHTML.

Since JavaScript is mainly used for XHTML, it makes some sense to just use XHTML for its documentation. The downside to this is that there is currently no way to parse out the documentation, AFAIK. The format for putting the docs into comments would have to be standardized. I don’t really see that happening.

Use POD.

JavaScript is a dynamic language; it’d make some sense to use the documentation format of an existing dynamic language. And POD is a proven format. The downside, of course, is that there is not a parser for pulling POD out of a .js file. Same problem as for XHTML, essentially.

Use JavaDoc

Since the syntax of JavaScript is roughly based on JavaScript, and JavaScript supports the same comment syntax, one could simply use the JavaDoc format. The javadoc application probably couldn’t parse it out too well, since it parses the Java code (or byte code?) to automatically document method names, signatures, etc.

But a quick Googling yields JSDoc as a possible solution. The only downside to the JavaDoc/JSDoc solution is that it tends to allow authors to be too lazy. Since the application automatically documents the existence of functions and their signatures, often little else is documented. But that’s mainly a personal issue; I don’t have to be so lazy in my own documentation! I think I’ll give that a shot.

Meanwhile, if anyone knows of something better/more widely used, let me know!

Comments & Trackbacks

Chris Dolan wrote:

Not a solution, but here's a hint. Actionscript, the programming language behind Flash, is an ECMAscript variant. I use POD demarked like so:

/*

=head1 Documentation

This is POD documentation

=cut
*/

Then you can use standard Perl tools like pod2html or pod2txt. It's important to have a blank line between the "/*" and the first "=" line.

Alternatively, the Actionscript community has largely latched onto Javadoc syntax, following the lead of the influential Colin Moock I believe. Below are some resources for parsing Javadoc out of Actionscript. I imagine that one of those could handle Javascript with very little change.

http://as2documentor.sourceforge.net/
http://www.asdocgen.org/blog/

Powered by KinoSearch