Skip to content
nene edited this page Aug 1, 2012 · 15 revisions

(Updated for beta 2 release.)

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.

New tags @enum and @since bring on table completely new features.

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 + @inheritable 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 the easiest option is to download the jsduck-4.0.beta2.exe binary. It should work out of the box. (The previous beta also offered a JRuby version, but this was just an experiment, and has been discontinued.)

Alternatively you can install through rubygems, but you need to do some additional tweaks. First go and download therubyracer gem and v8 lib that stereobooster has built for windows. You need to install this special rubyracer version instead of the one from rubygems:

> gem install therubyracer-0.11.0beta1-x86-mingw32.gem

To make it actually work you need v8.dll somewhere in your system. Extract the lib_v8.3.11.9.zip take the v8.dll inside it and place into the bin directory of your Ruby installation (other dirs that are on your PATH can work too, but I've found this to be the most sensible place to put it). Now you're ready to install JSDuck:

> gem install jsduck --pre

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