简体   繁体   中英

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.

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

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完成

  • and soon with validation:

JSDoc验证

This support is not perfect but it starts working.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM