有什么方法可以在 Eclipse 中自动生成所有 Javadoc 注释?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2530043/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Any way to auto generate ALL Javadoc comments in Eclipse?
提问by Finbarr
I know that you can press shift+alt+j to insert an appropriate comment template for the current code block, but is there any way to let eclipse just go crazy and do a whole project like this?
我知道你可以按 shift+alt+j 为当前代码块插入一个合适的注释模板,但是有什么方法可以让 eclipse 发疯并做一个这样的整个项目?
回答by VonC
For a wholeproject, may be not, but you can at least:
对于整个项目,可能不是,但您至少可以:
- go to the Package Explorer View
- expand the class you want to generate comment on (open each method)
- select all the opened elements in the class from that Package Explorer Tree
- alt+shift+Jand voilà: comments generated on the class, and every method
- 转到包资源管理器视图
- 展开要生成评论的类(打开每个方法)
- 从该包资源管理器树中选择类中所有打开的元素
- alt+ shift+J和 voilà:在类和每个方法上生成的注释
The only reason it is not practical for the all project is:
它对所有项目都不实用的唯一原因是:
- you need to open every class you want to generate comments on
- once a first set of methods have been commented, you still need to repeat the process if you have written new methods.
- 你需要打开每一个你想发表评论的课程
- 一旦注释了第一组方法,如果您编写了新方法,您仍然需要重复该过程。
That being said, another approach is described in the article "The Problem of Incomplete Javadocs" from March, 30th 2010, advocating for an extended Javadoc view.
话虽如此,2010 年 3 月 30 日的文章“不完整的 Javadoc 的问题”中描述了另一种方法,提倡扩展 Javadoc 视图。
The extended Javadoc View is essentially an aggregator of different information sources for a single code element like a class, method, field or parameter. It is designed as a replacement for the existing Eclipse Javadoc.
扩展的 Javadoc 视图本质上是单个代码元素(如类、方法、字段或参数)的不同信息源的聚合器。它旨在替代现有的 Eclipse Javadoc。
The interesting part comes with the other tabs in the view: Subclassing Directives and Subclassing Patterns.
These tabs contain mined information about how developers typically extended the selected code element.
有趣的部分来自视图中的其他选项卡:Subclassing Directives 和 Subclassing Patterns。
这些选项卡包含有关开发人员通常如何扩展所选代码元素的挖掘信息。
- Subclassing tab:
- 子类化选项卡:
subclassing directives are generalizations of frequently made observations in example code like "Subclasses of Wizard always override its method
addPages()
" or "Reimplementors
ofDialog.createContents()
may call its super implementation".
继承指令就像在示例代码中经常提出的意见概括“精灵的子类总是覆盖的方法
addPages()
”或“Reimplementors
中Dialog.createContents()
可以调用它的超强执行”。
- Subclassing Patterns Tab
- 子类化模式选项卡
Subclassing patterns try to group observed extensions of a base class into typical extension patterns, i.e., they cluster subclasses by similarity to find patterns in data.
子类模式试图将观察到的基类扩展分组为典型的扩展模式,即它们通过相似性对子类进行聚类以在数据中找到模式。
回答by Arun
I was also looking for an auto javadoc tool for eclipse and found one called JAutodoc.
我也在寻找一个用于 Eclipse 的自动 javadoc 工具,并找到了一个名为JAutodoc 的工具。
This tool generates comments pretty well and requires only minor changes manually in some places (if you require). In my opinion, this tool can save approximately 75% of the time spent in writing comments.
这个工具可以很好地生成注释,并且只需要在某些地方手动进行少量更改(如果需要)。在我看来,这个工具可以节省大约 75% 的时间写评论。
You may visit herefor detailed instructions on downloading and integrating it with eclipse.
您可以访问此处获取有关下载并将其与 Eclipse 集成的详细说明。