Created
December 14, 2010 16:08
-
-
Save rwaldron/740633 to your computer and use it in GitHub Desktop.
An example from the JSDoc #usage page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage example revised | |
/** | |
* Shape is an abstract base class. It is defined simply | |
* to have something to inherit from for geometric | |
* subclasses | |
* @constructor | |
*/ | |
function Shape( color ) { | |
this.color = color; | |
} | |
/** | |
* Get the name of the color for this shape | |
* @returns A color string for this shape | |
*/ | |
Shape.prototype.getColor = function() { | |
return this.color; | |
} | |
/** | |
* Circle is a subclass of Shape | |
*/ | |
function Circle( radius ){ | |
this.radius = radius; | |
} | |
/** | |
* Circle inherits Shape | |
*/ | |
Circle.prototype = new Shape( null ); | |
/** | |
* A very rough value for pi | |
*/ | |
Circle.PI = 3.14; | |
/** | |
* Get the radius of this circle | |
* @returns The radius of this circle | |
*/ | |
Circle.prototype.getRadius = function() { | |
return this.radius; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Shape is an abstract base class. It is defined simply | |
* to have something to inherit from for geometric | |
* subclasses | |
* @constructor | |
*/ | |
function Shape(color){ | |
this.color = color; | |
} | |
// Bind the Shape_getColor method to the Shape class | |
Shape.prototype.getColor = Shape_getColor; | |
/** | |
* Get the name of the color for this shape | |
* @returns A color string for this shape | |
*/ | |
function Shape_getColor(){ | |
return this.color; | |
} | |
/** | |
* Circle is a subclass of Shape | |
*/ | |
function Circle(radius){ | |
this.radius = radius; | |
} | |
/** | |
* A very rough value for pi | |
*/ | |
Circle.PI = 3.14; | |
/** | |
* Get the radius of this circle | |
* @returns The radius of this circle | |
*/ | |
function Circle_getRadius(){ | |
return this.radius; | |
} | |
// Circle is a subclass of Shape | |
Circle.prototype = new Shape(null); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment