digplanet beta 1: Athena
Share digplanet:

Agriculture

Applied sciences

Arts

Belief

Business

Chronology

Culture

Education

Environment

Geography

Health

History

Humanities

Language

Law

Life

Mathematics

Nature

People

Politics

Science

Society

Technology

JSDoc is a syntax for adding inline API documentation to JavaScript source code. This is distinct from the various tools that parse and manipulate code that follows the JSDoc syntax.

The JSDoc syntax is similar to the Javadoc syntax, used for documenting Java code, but is specialized to work with JavaScript's more dynamic syntax and therefore unique, as it is not completely compatible with Javadoc. However, like Javadoc, JSDoc allows the programmer to create doclets and tags which can then be translated into published output, like HTML or RTF.

Contents

JSDoc tags [edit]

Although this list is incomplete, the following annotations are commonly used in modern JSDoc.

Tag Description
@author Developer's name
@constructor Marks a function as a constructor
@deprecated Marks a method as deprecated
@exception Synonym for @throws
@param Documents a method parameter; a datatype indicator can be added between curly braces
@private Signifies that a method is private
@return Documents a return value
@see Documents an association to another object
@this Specifies the type of the object to which the keyword "this" refers within a function.
@throws Documents an exception thrown by a method
@version Provides the version number of a library

Example [edit]

An example of JSDoc usage.

/**
 * Creates an instance of Circle.
 *
 * @constructor
 * @this {Circle}
 * @param {number} r The desired radius of the circle.
 */
function Circle(r) {
    /** @private */ this.radius = r;
    /** @private */ this.circumference = 2 * Math.PI * r;
}
 
/**
 * Creates a new Circle from a diameter.
 *
 * @param {number} d The desired diameter of the circle.
 * @return {Circle} The new Circle object.
 */
Circle.fromDiameter = function (d) {
    return new Circle(d / 2);
};
 
/**
 * Calculates the circumference of the Circle.
 *
 * @deprecated
 * @this {Circle}
 * @return {number} The circumference of the circle.
 */
Circle.prototype.calculateCircumference = function () {
    return 2 * Math.PI * this.radius;
};
 
/**
 * Returns the pre-computed circumference of the Circle.
 *
 * @this {Circle}
 * @return {number} The circumference of the circle.
 */
Circle.prototype.getCircumference = function () {
    return this.circumference;
};
 
/**
 * Find a String representation of the Circle.
 *
 * @override
 * @this {Circle}
 * @return {string} Human-readable representation of this Circle.
 */
Circle.prototype.toString = function () {
    return "A Circle object with radius of " + this.radius + ".";
};

History [edit]

The earliest example of using a Javadoc-like syntax to document JavaScript was released in 1999 with the Netscape/Mozilla project named Rhino.

JSDoc In Use [edit]

  • Google's Closure Linter and Closure Compiler [1]. The latter extracts the type information to optimize its output JavaScript.
  • The JSDoc syntax has been described at length in the Apress book Foundations of Ajax ISBN 1-59059-582-3.
  • IntelliJ IDEA, NetBeans and RubyMine understand JSDoc syntax.
  • The Eclipse IDE has extensions that understand the JSDoc syntax. Eclipse-based Aptana Studio supports ScriptDoc, and the included JavaScript files are commented in ScriptDoc.
  • Mozile, the Mozilla Inline Editor uses JSDoc.
  • The Helma application framework uses JSDoc.
  • SproutCore documentation was generated using JSDoc. [2]

See also [edit]

External links [edit]


Original courtesy of Wikipedia: http://en.wikipedia.org/wiki/JSDoc — Please support Wikipedia.
A portion of the proceeds from advertising on Digplanet goes to supporting Wikipedia.
27 videos foundNext > 

Komodo IDE: Better JavaScript calltips using JSDoc comments.

A short demonstration of how to use JSDoc-style comments to provide type hinting and more descriptive calltips in ActiveState's Komodo IDE. Visit http://www....

PhpStorm und JsDoc - Toolkit

PhpStorm und JsDoc - Toolkit.

Funniest baby laugh

Brennen laughing at his goofy mommy !

Mua Lan Dang Khoa Jan 2012_3

PHPStorm - WI-8922

Incorrect End Of File (EOF) Detection.

Eiffel 65 - Blue

ペントミノをJavaScriptで解く

設置ボタンは1コずつの設置。 それをブレイクカウントに達するまで連続して行うのが自動ボタン。 解析途中を保存し再開することができ、セーブ情報を左の縦長のエリアに貼ってリストアボタン。 保存はセーブボタンを押すと、左の縦長のエリアに現状出力されるので、それをコピーして残しておく。 動画の内容は、セーブ情報をリストア...

Xdebug Installation

Aufgaben der Php Erweiterung Xdebug, sowie die Installation.

VALERA - Was von Uns übrig bleibt

Ein gefühlvoller Track von Valera mit dem sich viele Leute identifizieren können. Viel Spass mit dem Track Besucht Bryka Studios und MCValeraTV Channel www.f...

How to change style in phpstorm

How to change style in phpstorm 3.0. And font like in Mac osx.

27 videos foundNext > 

We're sorry, but there's no news about "JSDoc" right now.

Loading

Oops, we seem to be having trouble contacting Twitter

Talk About JSDoc

You can talk about JSDoc with people all over the world in our discussions.

Support Wikipedia

A portion of the proceeds from advertising on Digplanet goes to supporting Wikipedia. Please add your support for Wikipedia!