perl
JSDoc: How to document your JavaScript
JSDoc is meant to do for Javascript, what Javadoc does for Java.
It does.
You can download and install JSDoc easily:
- Download JSDoc
- Expand the tgz.gz file (I use Winrar)
- Optional – I copy the jsdoc folder to my C: drive to make things easier
- Reminder – you need a perl runtime installed. ActivePerl is recommended
- Open up a command prompt
- Change to your JSDoc folder (mine is c:\JSDoc-1.10.2\)
- Run it: “perl jsdoc.pl test.js” (to test it against the built in JS file)
Usage of JSDoc is as simple as Javadoc was. An example of usage taken from the official JSDoc page is below:
[sourcecode language='jscript']/**
* 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);
[/sourcecode]
You can use the reference on the official site to learn about more of the “@” attributes you can use for JSDoc.
The example code is here:
- test.js – original example javascript file
- JSDoc generated documentation for the test.js file.
Please share, it makes me happy:
Subscribe to Email Alerts
Make a Donation
Popular Posts
Follow Me
Recent Posts
Archives
Tags
Blogroll
- 456 Berea St
- ActionScript 3 Design Patterns
- adactio – home of Jeremy Keith
- ajaxian
- Boxes and Arrows
- Chris Brogan
- CSS Globe
- InsideRIA
- Jarrod Michael Studios
- Johan Brook: Designer and Developer
- Mad Vertices
- NETTUTS
- Portsmouth Community Calendar
- Roomware Blog
- Signal vs. Noise
- Six Revisions
- Snook
- Style Grind
- Tiago’s Weblog
- Viget Extend
- Vitamin
- Whats the latest
- Woork
- zupko.info
