Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any tool for commenting JavaScript code? [closed]

Is there any tool for javascript commenting as it is in c# like ghost doc.

/// <summary>
///   Method to calculate distance between two points
/// </summary>
/// <param name="pointA">First point</param>
/// <param name="pointB">Second point</param>
function calculatePointDistance(pointA, pointB)
 { 
    ... 
 }

there any tool to automatically add the comments like above. like in c# code ghost doc did:

/// <summary>
///   Method to calculate distance between two points
/// </summary>
/// <param name="pointA">First point</param>
/// <param name="pointB">Second point</param>
private void calculatePointDistance(pointA, pointB)
{
  .....
}

i want to do the similar in Client side ,javascript

like image 809
Vijjendra Avatar asked Oct 20 '09 16:10

Vijjendra


2 Answers

Yes (but more like Javadoc) - look at JSDoc Basically you use Javadoc-like special syntax in your comments e.g. @param like in the following example and then parser will generate good looking HTML output for you

/**
* 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;
}
like image 165
Bostone Avatar answered Oct 16 '22 15:10

Bostone


The short answer is no, there is nothing that automates the documentation. The closes you get is manually adding comments with something like jsdoc-toolkit that allows building the documentation into html pages.

There is intellisense documentation for javascript for javascript as well, which looks like this (notice it is inside the function though)

function example(var myParameter){
    /// <summary>This is an example function</summary>
    /// <param name="myParameter" type="String">All your string are belong to us.</param>
    /// <returns type="Boolean" />

   return !!myParameter;
}

You can also create snippets for javascript files. I would just create a few snippets filling out common documentations (any type you prefer) and then you can just type the snippet and it will fill in most of the documentation for you.

like image 31
Gordon Tucker Avatar answered Oct 16 '22 15:10

Gordon Tucker