简体   繁体   English

如何在Eclipse中附加JSdoc,以便我可以为个人库自动完成

[英]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. 我目前正在处理一个JavaScript库。 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!). 这些模块是使用命名空间函数动态命名的,这意味着自动完成几乎是不可能的(除非Eclipse可以运行我的代码并找出命名空间,Visual Studio可以!)。

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. 因此,我打算为我的项目生成JSdoc,希望如果我将它包含在Eclipse中(不知何故),Eclipse可以使用它来为我提供内容帮助。

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" “JSDT库是具有原型对象/类定义和JSDoc的JavaScript源文件的集合。推理引擎然后对这些库进行建模......使它们可用于项目中的每个JavaScript文件...非标准和未来运行时的绑定类似易于创建...将...库添加到他们的项目并获得内容完成和悬停帮助“

I know how to write JSdoc annotations and I know how to generate JSdoc using one of the various tools. 我知道如何编写JSdoc注释,我知道如何使用各种工具之一生成JSdoc。

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. 因此,我需要的是有关如何在Eclipse中包含JSdoc(作为库)的说明,以便它可以自动完成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. 取自 Google网上论坛主题。

Updated Answer: 更新答案:

Eclipse JavaScript Editor: content assist for js files, autocompletion Eclipse JavaScript Editor:js文件的内容辅助,自动完成

Disclaimer, I'm the author of tern.java . 免责声明,我是tern.java的作者。

I suggest you that you install tern.java . 我建议你安装tern.java It provides a JSDoc support . 它提供了JSDoc支持 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. 我不是自己使用它,所以我不确定它是否有效,但是jsdoc3存在一个grunt-plugin。 Grunt is supported by Eclipse. Eclipse支持Grunt。 So maybe it helps. 所以也许有帮助。

Grunt-PlugIn in npm gpm中的Grunt-PlugIn

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何使用 jsdoc 注释注释 React.forwardRef 以便智能感知可以显示在底层组件中? - How do i annotate React.forwardRef with jsdoc comments so that intellisense can show up for the underlying component? 如果Eclipse中缺少jsDoc批注,如何获得警告? - How do I get warnings if jsDoc annotations are missing in eclipse? JsDoc:如何记录对象可以具有任意(未知)属性但具有特定类型? - JsDoc: How do I document that an object can have arbritrary (unknown) properties but with a particular type? 如何将画布附加到回形针上,以便将其保存到数据库中? - How do I get a canvas to attach to paperclip so I can save it into my database? jQuery autocomplete。当您具有autocomplete并按“ enter”时,我不想搜索,实际上它会搜索 - jquery autocomplete .When you have the autocomplete and press 'enter',i do not want to search ,actually it will do search 如何运行 eslint 以便我可以附加调试器? - How to run eslint so that I can attach a debugger? 如何使用 JSDoc 记录对象? - How do I document an object with JSDoc? JSDoc:我如何记录`var self = this;`? - JSDoc: How do I document `var self = this;`? JsDoc:如何仅记录 object - JsDoc: How do I document an object only 如何在 Windows 上使用 JSDoc? - How do I use JSDoc on Windows?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM