2008年11月14日金曜日

Introduction to JavaScript Documentation by JSDoc

When you create a genuine Web Application and it seems to a lot of JavaScript scripts added day by day, you'll be better to use tools for documentation of them to grasp and understand present situation of your project.

JS Doc is a very helping tool for you in such situation to document source codes written in JavaScript.

Usage

Download the JSDoc tarball from Sourceforge and install it as below:
# Download the latest JSDoc
$ wget "http://downloads.sourceforge.net/jsdoc/JSDoc-1.10.2.tgz"
$ tar xvzf JSDoc-1.10.2.tgz
$ cd JSDoc-1.10.2
Now, you're ready to go.
You can immediately try out JSDoc on the included test.js JavaScript file by going into the JSDoc directory and entering the command:
$ perl jsdoc.pl test.js
This should output a set of HTML files in a directory called js_docs_out.
Go to "js_docs_out/index.html" by your browser, and you can see the documentation about your JavaScript codes.

This documentation tool seems to work when you implement the application along the object oriented notation, otherwise it doesn't work.

I have an error...

If you get an error message right away that looks something like:
Can't locate HTML/Template.pm in @INC ......
Then you will need to install the HTML::Template Perl module.
Open a terminal and run the following command as root:
$ sudo perl -MCPAN -e 'install HTML::Template'