Skip to content
nene edited this page Jun 27, 2012 · 15 revisions

JSDuck 4.0 beta is now out and brings with it a new JavaScript parser.

Using Esprima.js internally, JSDuck 4 has much improved auto-detection capabilities.

Example

/** My panel */
Ext.define("MyPanel", {
    extend: "Ext.panel.Panel",

    config: {
        /**
         * Title for the panel
         */
        title: "Untitled"
    },

    inheritableStatics: {
        /**
         * Registers the panel globally.
         * @param {MyPanel} panel
         */
        register: function(panel) {
        }
    },
    
    floating: false
});

From the above code JSDuck 4 detects config option title, static method register and private property floating. In JSDuck 3 you would have needed to explicitly use @cfg + @accessor tags for the config option, @static + @ingeritable tag for static method, and the private property would have needed a doc-comment with @private tag.

Getting it

To install 4.0 beta, run:

$ gem install jsduck --pre

Additionally you should install therubyracer gem which provides a fast v8 bridge for running esprima.js:

$ gem install therubyracer

In Windows download the jsduck-4.0.beta.exe binary. It should work out of the box, but it will be terribly slow as it's using the Windows JScript host by default. To speed things up install NodeJS (make sure you also add node executable to your PATH). It will still be slower than JSDuck 3, but at least the speed should be bearable.

Hacking

Check out the esprima-parser branch:

$ cd jsduck
$ git checkout esprima-parser

Clone my fork of esprima.js into a subdir and check out linenr-in-range branch:

$ git clone git://github.com/nene/esprima.git
$ cd esprima
$ git checkout linenr-in-range

Ensure unit tests are passing:

$ cd ..
$ rake

Have fun :)

Clone this wiki locally