Jsdoc toolkit Introduction

jsdoc toolkit是一個能夠將javascript註解產成文件的工具。 tag的寫法和download可以參考相關資訊。 以下是一個簡單的example:

/**
* @author Sparrow
*/

/**
* @class Dog is an animal.
* @constructor
*/
function Dog(){

    var _name;

    /**
    * @description Set the dog name.
    * @param {string} name
    */
    this.setName = function(name){
        _name = name;
    }

    /**
    * @description Get the dog name.
    * @type String
    */
    this.getName = function(){
        return _name;
    }

}

/**
* @description Attack a target.
* @param {String} target
*/
Dog.prototype.attack = function(target){
    alert("attack:"+target);
}

最後只要在terminal執行以下指令: java -jar jsrun.jar app/run.js Dog.js -t=templates/jsdoc/