views:

273

answers:

5

Hi All, 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

+5  A: 

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;
}
DroidIn.net
He's after a Visual Studio plugin that would automate XML documentation creation. GhostDoc creates documentation stubs so devs don't have to write all by themselves. (-1 from me)...
Robert Koritnik
And what's your point? If you read my comment - Ghostdoc will not do it for him - so I'm providing the guy with a valuable alternative. Or you just enjoy it?
DroidIn.net
A: 

I haven't personally used it, but jsdoc-toolkit seems to be what you're after.

etheros
+1  A: 

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(string 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.

Gordon Tucker
A: 

I haven't used it for JavaScript, but Doxygen has a filter that allows it to (at least to some extent) be used to document JavaScript. It might be worth looking into, especially if you are using other languages that are also supported by Doxygen, so you can have one tool for everything.

It appears that JSUnit uses Doxygen for its documentation.

Thomas Owens
Ya, I tried that but I never got that filter to work :(
Justin Johnson
A: 

Sandcastle appears to support JavaScript as well, see http://blogs.msdn.com/sandcastle/archive/2007/06/28/scriptdoc-1-0-for-extractiong-javascript-code-comments-is-now-available-at-codeplex.aspx. I use it for C# since the NDoc project is toast, but haven't tried it for JavaScript yet. I used to use JSDoc mentioned above.

nickyt