There are several reasons why documentation is important:
DocumentJS is a new documentation solution for JavaScript applications. It makes creating, viewing, and maintaining documentation easy and fun. Out of the box, it features:
DocumentJS provides powerful and easy to extend documentation functionality. It's smart enough to guess at things like function names and parameters, but powerful enough to generate JavaScriptMVC's entire website!
Let's use an hypothetical little CRM system as an example of how easy it is to organize your documentation with DocumentJS.
First let's create our CRM documentation home page by creating a folder name crm. Paste this code into a file named crm.js inside crm folder.
/*
* @page crm CRM
* @tag home
*
* ###Little CRM
*
* Our little CRM only has two classes:
*
* * Customer
* * Order
*/
Run the documentjs script to generate the docs:
documentjs/doc.bat crm
This is what you should see when you open crm\docs.html:

There are a few things to notice:
Next we document the two classes that make our little crm system. Paste each snippet of code into two files with names customer.js and order.js:
customer.js
/*
* @class Customer
* @parent crm
* @constructor
* Creates a new customer.
* @param {String} name
*/
var Customer = function(name) {
this.name = name;
}
order.js
/*
* @class Order
* @parent crm
* @constructor
* Creates a new order.
* @param {String} id
*/
var Order = function(id) {
this.id = id;
}
After runnig the documentjs script once again you should be able to see this:

We want to be able to both look for our customer's orders and dispatch them so let's add a findById method to our Order class and a dispatch method to our Order's prototype:
order.js
/*
* @class Order
* @parent crm
* @constructor
* Creates a new order.
* @param {String} id
*/
var Order = function(id) {
this.id = id;
}
$.extend(Order,
/*
* @static
*/
{
/*
* Finds an order by id.
* @param {String} id Order identification number.
* @param {Date} [date] Filter order search by this date.
*/
findById: function(id, date) {
}
});
$.extend(Order.prototype,
/*
* @prototype
*/
{
/*
* Dispatch an order.
* @return {Boolean} Returns true if order dispatched successfully.
*/
dispatch: function() {
}
});
Go ahead and produce the docs by running the documentjs script. You should see your Order methods organized by static and protoype categories.
There's one last thing we need to cover - customizing the document viewer template. The default viewer template file name is summary.ejs and it's located in documentjs/jmvcdoc/summary.ejs. You can use a customized template by copying summary.ejs into the crm folder and changing it according to your needs. Let's try changing the navigation menu core item to crm:
<li class="ui-menu-item">
<a class="menuLink" href="#&search=crm"><span class="menuSpan">CRM</span></a>
</li>
Remember the @tag directive? We can now change it in our examples from core to crm. You will notice that our crm page will show up every time you click the CRM menu item or type crm in the documentation viewer search box.
If you need for DocumentJS not to document a particular script you can do that by adding the @document-ignore directive to the top of the file.
As you see DocumentJS makes it super easy and fun to organize your documentation!
DocumentJS architecture is organized around the concepts of types and tags. Types are meant to represent every javascript construct you might want to comment like classes, functions and attributes. Tags add aditional information to the comments of the type being processed.
DocumentJS works by loading a set of javascript files, then by spliting each file into type/comments pairs and finally parsing each type's comments tag directives to produce a set of jsonp files (one per type) that are used by the document viewer (jmvcdoc) to render the documentation.
DocumentJS was written thinking of extensibility and it's very easy to add custom type/tag directives to handle your specific documentation needs.
DocumentJS was inspired by the jQuery API Browser by Remy Sharp
DocumentJS(scripts, options)
{Array|String}
an array of script objects that have src and text properties like:
[{src: "path/to/file.js", text: "var a= 1;"}, { ... }]
{Object}
an options hash including
. name - the name of the application . out - where to generate the documentation files