Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you attach JSdoc in Eclipse so that I can have autocomplete for a personal library

I have a JavaScript library that I am working on currently. I have structured it into lots of files and I use the module approach to define each 'module'.

var ns = generateNamespace("me.mycompany.mypackage.MyFile");

(function (ns, undefined) {
    // some module 
}(ns));

The modules are dynamically named using a namespacing function meaning that autocomplete is almost impossible as things stand (unless Eclipse can run my code and figure out the namespaces, Visual Studio can!).

Therefore I intend to generate JSdoc for my project in the hope that if I include this into Eclipse (somehow) Eclipse can use this to give me content assist.

Firstly I do not know if this is possible... however I think that it is as I can see that it is maybe how this works? However I tried to follow this along and struggled to get something working, by this I mean it didn't work. The interesting info from the link:

"JSDT libraries are collections of JavaScript source files that have prototyped object/class definitions and JSDoc. The inference engine then models these libraries... making them available to every JavaScript file in the project... Bindings for nonstandard and future runtimes are similarly easy to create... add the... library to their project and gain content completion and hover help"

I know how to write JSdoc annotations and I know how to generate JSdoc using one of the various tools.

What I need therefore is instructions on how to include JSdoc (as a library maybe) in Eclipse so that it will give auto complete for the stuff in the JSdoc.

like image 307
Neilos Avatar asked Feb 20 '13 18:02

Neilos


2 Answers

Previous answer:

You can also run jsdoc_toolkit from within eclipse by setting up Run -
> External Tools -> Open External Tools Dialog...

Location
C:\Program Files\Java\jre1.5.0_12\bin\java.exe

Working Directory
C:\DirectoryToWhereJsDocToolkitIsLocated\jsdoc_toolkit

Arguments
-jar app/js.jar app/run.js -r=4 -t=templates/htm "-d=C:
\PathToWhereDocIsSaved" "C:\PathToWebsiteToDocument"

For more about the arguments check the jsdoc_toolkit documentation.

Have fun
Simon

Taken from this Google Groups thread.

Updated Answer:

Eclipse JavaScript Editor: content assist for js files, autocompletion

like image 50
CBusBus Avatar answered Oct 08 '22 20:10

CBusBus


Disclaimer, I'm the author of tern.java.

I suggest you that you install tern.java. It provides a JSDoc support. Once you have selected this support, you can benefit

  • with completion :

JSDoc completion

  • and soon with validation:

JSDoc validation

This support is not perfect but it starts working.

like image 39
Angelo Avatar answered Oct 08 '22 19:10

Angelo