BishopZ
BishopZ

Reputation: 6378

How to get Eclipse to do auto-javadoc comments in Javascript document

When writing a javascript function in Eclipse, I would like to use the auto-commenting feature. I have seen it work on other people's computers, but it is not grabbing the @params on my machines.

When I have

var foo = function(bar){
    // do stuff
    return bar;
}

And on the line before the function I type /** and hit return, I get:

/**
 * 
 */
var foo = function(bar){
    // do stuff
    return bar;
}

I should get:

/**
 * 
 * @param bar
 */
var foo = function(bar){
    // do stuff
    return bar;
}

Any ideas? This seems like some setting in Eclipse is not set right, rather than a problem specific to Javascript.

Upvotes: 4

Views: 6048

Answers (3)

Bikush
Bikush

Reputation: 694

Try declaring your functions like this:

function foo(bar){
   return bar;
};

Thing is that Eclipse generates documentation for declarations! An assignment expression you use to declare a function is no different than an expression like x=1; and Eclipse does not generate documentation for expressions.

I would recommend checking out this question. It explains the differences in function declarations.

Upvotes: 3

nitind
nitind

Reputation: 20023

Assuming Juno and a file on the project's Include Path, you want to Generate the "element" comment (either from the Outline view or Source menu or the Add JSDoc Comment command) rather than do so by typing it in, although when I tried it it didn't quite come out as neatly as I expected.

Upvotes: 1

Simulant
Simulant

Reputation: 20142

I am not using JavaScript, just pure Java, but the setup for generated Java-Code comments is here:

Window -> preferences -> Java -> Code Style -> Code Templates  ->
 Comments -> Methods

the default value is :

/**
 * ${tags}
 */

so i guess you need to set up somthing similar in Window -> preferences -> JavaScript -> ...

Upvotes: 0

Related Questions