views:

1031

answers:

7

Is there a standard/tool for documenting JavasSript? I'm thinking of something similar to Javadoc.

A: 

No, unfortunately there is no standard.

There are, however, quite a few tools that do similar functions.

This wikipedia page covers these tools in depth. For our project we're using robodoc.

chills42
+3  A: 

No, not widely accepted, but ScriptDoc approach will seem familiar to you if you know Java documentation techniques using the JavaDoc tool, but it has not fully been accepted yet to industry.

TStamper
@TStamper: FYI in the link you provided there is no ScriptDoc, they say it's integrated into Aptana Studio now. It seems a bit complex to just do Javascript documentation.
Marco Demajo
+4  A: 

Duplicate: What options are available for documenting your Javascript code?

The 800-pound gorilla of Javascript documentation is the JSDoc Toolkit. Check it out here. Most of the documentation is done with Javadoc-like tags and a /** comment prefix.

Example:

var MyClass = Class.create(
  /** @lends MyClass# */              // @lends is how you document anonymous classes.
  {
    /**
     * Description of constructor.
     * @class Description of class.   // @class annotation goes anywhere and
     *                                //   describes the whole class.
     * @constructs                    // This is a constructor.
     */
    initialize: function(arg0, arg1) {
      //...
    },

    /** A method. */
    myFunc: function() {},

    /** An instance field. */
    myVar: 123
  }
);

Object.extend(MyClass,
  /** @lends MyClass */
  {
    /** A class method. */
    classFunc: function() {}
  }
);

You can also do NaturalDocs...

altCognito
Not really a duplicate, but similar
TStamper
Natural Docs requires PERL to work.
Marco Demajo
+1  A: 

Personally, I'm a huge fan of Doxygen. While Javascript isn't one of the officially supported languages, there is a helper script that's supposed to make it work. (I haven't tried Doxygen with Javacript myself, but I did get it working on several hundred thousand lines of Delphi / Pascal code, and JS must be easier.)

Electrons_Ahoy
+1  A: 

There is JSDoc and the Ruby powered Pdoc. There's not really an accepted "standard" but JSDoc probably comes the closest.

Mark W
JSDoc requires PERL to work;
Marco Demajo
+1  A: 

You can also use the documentor created for ExtJS: http://code.google.com/p/ext-doc/.

Its amazing, with support for custom tags and fully templated output. It comes with a nice XSL sheet for transforming the output into something useful (the sample obviously converts to the ExtJS style of documentation).

I've used it in my projects with great success.

Check out the thread on it here: http://extjs.com/forum/showthread.php?t=55214

jvenema
Ext Doc creates heavy Ext-style documentation (not simpe, HTML/CSS documentation);
Marco Demajo
Ext Doc uses an XSL stylesheet and templates; you can convert it to whatever you want.
jvenema
A: 

A little too verbose for my liking... but, YUI Doc seems to have some legs.

couchoud
YUI Doc requires PHYTON to work;
Marco Demajo