为 java 项目生成 javadoc

发布于 2024-09-08 06:20:32 字数 257 浏览 5 评论 0原文

最近我们计划在我们的项目中使用checkstyle插件。作为此练习的一部分,必须清理现有代码以符合检查样式规则。我们发现接近 18K 的违规行为与类文件中缺少 javadoc 注释相对应。

我的问题是,是否有任何插件或工具可以用来为整个工件生成 javadoc 注释? 我查看了 JAutodoc ,我会 想知道是否还有比这更好的事情。

Recently we planned to use checkstyle plug-in in our project. As a part of this exercise existing code has to be cleaned up to comply with checkstyle rules. We have found that close to 18K violations correspond to absence of javadoc comments in class files.

My question is, is there any plugin or tool which i can use to generate javadoc comments for the entire artifacts?
I had a look at JAutodoc , and I would
like to know whether there is anything better than this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

长伴 2024-09-15 06:20:32

即使 CheckStyle 分数上升,您的实际代码质量也会因生成 JavaDoc 而下降。生成的 JavaDoc 只能反映代码中已经显而易见的内容,它增加了体积,从而降低了可读性,并且它可能(取决于您的工具)不会保持最新状态,增加了维护负担并导致代码演变后的不一致。

不要让自己的代码变得混乱。 CheckStyle 违规行为应被视为提示,而不是绝对的铁定规则。添加合理的 JavaDoc 需要时间和对代码的理解,您应该制定从现在开始在所有新代码中创建它的策略,并在重构时将其添加到任何现有代码中。

顺便说一句:您不必将所有内容都记录在 JavaDoc 中。我个人不使用 JavDoc 默认的 getter/setter、覆盖或具有不言自明的名称的方法/字段(这是我努力的目标)。我总是使用 JavaDoc 顶级实体(接口、类和枚举)并将非 JavaDoc 注释放在执行复杂操作的代码块上。

Your real code quality will go down by generating JavaDoc, even if the CheckStyle score goes up. Generated JavaDoc can only reflect what is already obvious from the code, it adds volume which decreases readability and it probably (depending on you tool) will not keep itself up to date, adding a maintenance burden and leading to inconsistencies after the code evolves.

Don't let yourself be badgered into cluttering your code. The CheckStyle violations should be taken as hints, not absolute iron-clad rules. Adding sensible JavaDoc takes time and understanding of the code, you should make policy for creating it from now on in all new code, and add it in any existing code when it gets refactored.

BTW: you don't have to JavaDoc everything. I personally don't JavDoc default getters/setters, overrides or methods/fields with self-explanatory names (which I strive for). I always JavaDoc top level entities (interfaces, classes and enums) and put non-JavaDoc comments on blocks of code that do something complicated.

潇烟暮雨 2024-09-15 06:20:32

如果您创建 NetBeans 项目,您可以要求它自动为您生成缺少的框架。只需在项目上单击鼠标右键即可选择菜单项,您将获得所有缺失的骨架。

另一个工具(需要花钱,但非常值得)是 Jalopy from triemax 的商业版本,这是一个非常好的工具代码格式化程序(开发人员反应非常灵敏,并且根据要求相对较快地添加新功能)。

If you create a NetBeans project you can ask it to automatically generate the missing skeletons for you. A simple right mouse click on the project to select the menu item and you will have all the missing skeletons in place.

Another tool (costs money, but well worth it) is the commercial version of Jalopy from triemax which is an excellent code formatter (the developer is super responsive and adds new features relatively quickly when requested).

纵山崖 2024-09-15 06:20:32

最近有同样的问题。我们刚刚更改了 checkstyle 配置文件,将缺失的 javadocs 仅设置为警告,直到我们的贡献者包含了缺失的文档。

这里描述了如何执行此操作链接文本,或者您可以使用 eclipse checkstyle 插件,它提供了GUI界面。

Had the same problem recently. We just changed the checkstyle configuration file to set missing javadocs only as warnings until our contributors have included the missing docs.

How to do this is decribed here link text, or you can use the eclipse checkstyle plugin which provides a GUI interface.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文