7

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.

Neilos
  • 2,696
  • 4
  • 25
  • 51

3 Answers3

1

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

Community
  • 1
  • 1
CBusBus
  • 2,321
  • 1
  • 18
  • 26
  • Thank you for your response. I have seen that email chain before.It is not quite what I am after, I know how to generate the JSdoc. I need to know how I can use the generated JSdoc in Eclipse to give me content assist for the stuff that the JSdoc covers. My question was a little unclear, I'll modify it. – Neilos Feb 21 '13 at 09:06
  • It appears that using Apatana may be your best option (discussed in link) – CBusBus Feb 21 '13 at 09:47
  • Aptana uses ScriptDoc not JSdoc which may or may not be a problem, I have looked into Aptana and found it was not quite up to the task, it looked nice but actually did not give me any auto completion at all (well at least none useful), even if I changed from the module pattern, this is why I am seeking other avenues (ie loading a JSdoc into Eclipse, which must be possible as it is how Eclipse handles auto-completion for the native JavaScript stuff). – Neilos Feb 21 '13 at 10:17
  • @Neilos I've linked another thread that appears to offer the solution. – CBusBus Feb 21 '13 at 18:00
  • Thank you again, unfortunately I am aware of and have tested the solution posted in that answer, it only solves half of the problem, it will not solve the issue of dynamically created namespaces and variables (it also suffers from other problems). I do think the only solution that will 100% work is linking some generated JSdoc to the project as a 'user library' under the include path of JavaScript (which is under project properties). I'll try to figure it out and when I do I'll post the solution here. – Neilos Feb 22 '13 at 09:12
1

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.

Angelo
  • 2,027
  • 13
  • 17
0

I am not using it by myself, so I'm not sure if it works, but there exists a grunt-plugin for jsdoc3. Grunt is supported by Eclipse. So maybe it helps.

Grunt-PlugIn in npm

selcox
  • 15
  • 4