What is it?
JsDoc Toolkit is an application, written in JavaScript, for automatically generating template-formatted, multi-page HTML (or XML, JSON, or any other text-based) documentation from commented JavaScript source code.
Based on the JSDoc.pm project, this was renamed into "Jsdoc Toolkit" during development as it grew into more than a simple version upgrade.
Site
http://code.google.com/p/jsdoc-toolkit/
JSDoc in our build
If you want to generate jsdocs run mvn jstools:jsdoc
How to use.
Class & Constructor | Other Tags |
/** * @class * @name BaseComponent * * @construtor * @param {String} componentId - component id * */ |
|
Field | |
/** * @name ClassName#fieldName * @type typeName * */
|
|
Static Field | |
/** * @constant * @name ClassName.fieldName * @type typeName * */
|
|
Method | |
/** * @methodOf * @name BaseComponent#toString * * @param userName * @param {String} username * @param {String|Number} product * @param {String[]} aliases * * @param {String} [accessLevel] * The user accessLevel is optional. * @param {String} [accessLevel="author"] * The user accessLevel is optional. * * @param userInfo Information about the user. * @param userInfo.name The name of the user. * @param userInfo.email The email of the user. * * @return {returnType} description * */
|
|
Static Method | |
/** * @methodOf * @name BaseComponent.getInstance * * @param {String} componentId - component id * @return {returnType} description * */
|
|
General Tags:
All Tags with descriptions http://code.google.com/p/jsdoc-toolkit/wiki/TagReference
| |
Examples
Example with inheritance.
(function (jQuery, richfaces, params) {
/**
* @class Base class for all component
* @name BaseComponent
*
* @constructor
* @param {String} componentId - component id
* */
richfaces.BaseComponent = function(componentId) {
this.id = componentId;
};
. . .
jQuery.extend(richfaces.BaseComponent.prototype, (function (params) {
return {
/**
* It is component name.
*
* @name BaseComponent#name
* @type String
* */
name: "BaseComponent",
/**
* Method for converting object to string
*
* @methodOf
* @name BaseComponent#toString
*
* @return {String}
* */
toString: function() {
. . .
}
};
})(params));
})(jQuery, window.RichFaces || (window.RichFaces = {}));
(function (jQuery, richfaces, params) {
/**
* Example of component implementation
*
* @class
* @name MyComponent
* @extends BaseComponent
*
* @constructor
* @param {String} componentId - component id
* */
richfaces.MyComponent = function(componentId) {
$super.constructor.call(this);
};
. . .
jQuery.extend(richfaces.MyComponent.prototype, (function (params) {
return {
/**
* MyComponent class name
*
* @name MyComponent#name
* @default MyComponent
* @type String
* */
name:"MyComponent",
/**
* Method with alert :)
*
* @methodOf
* @name MyComponent#func
* */
f:function () {
. . .
}
};
})(params));
})(jQuery, window.RichFaces || (window.RichFaces = {}));
Example with dynamically generated functions.
/**
* Class for Logging.
*
* @class
* @name RichFaces.Log
* @extends Object
*/
richfaces.log = (function(jQuery) {
var LOG_LEVELS = {
/**
* Ouput debug message
*
* @methodOf
* @name RichFaces.Log#debug
*
* @param {String} [text] output message
* */
'debug': 1,
/**
* Ouput info message
*
* @methodOf
* @name RichFaces.Log#info
*
* @param {String} [text] output message
* */
'info': 2,
/**
* Ouput warning message
*
* @methodOf
* @name RichFaces.Log#warn
*
* @param {String} [text] output message
* */
'warn': 3,
/**
* Ouput error message
*
* @methodOf
* @name RichFaces.Log#error
*
* @param {String} [text] output message
* */
'error': 4
};
/**
* @constant
* @name RichFaces.Log.LOG_LEVEL_COLORS
* @type Object
* */
var LOG_LEVEL_COLORS = {'debug': 'darkblue', 'info': 'blue', 'warn': 'gold', 'error': 'red'};
/**
* @constant
* @name RichFaces.Log.DEFAULT_LOG_LEVEL
* @type Number
* */
var DEFAULT_LOG_LEVEL = LOG_LEVELS['info'];
. . .
/**
* Strange function for strange class
* @methodOf
* @name RichFaces.Log#setLevel
*
* @param {debug|info|warn|error} [level=info] - output level
* */
var setLevel = function(level) {
. . .
};
var setLevelFromSelect = function(iLevel) {
currentLogLevel = iLevel || DEFAULT_LOG_LEVEL;
};
/**
* Clear log output
*
* @methodOf
* @name RichFaces.Log#clear
* */
var clear = function() {
. . .
};
. . .
Comments