用于私有方法的 JAVADOC (BlueJ)

发布于 2024-12-24 18:13:37 字数 156 浏览 0 评论 0原文

我正在使用 BlueJ,我想生成整个项目的 Javadoc。 我想在 Javadoc 上显示私有方法,有什么方法可以做到吗? BlueJ 有一个工具可以生成 Javadoc,但 BlueJ 忽略私有方法。 只是一个约定吗?如果这是一个约定,我不明白为什么,他们忽略“内部”方法,它们也很有用-.-*

I'm using BlueJ and I would like to generate the Javadoc of my whole project.
I would like to show private methods on the Javadoc, is there any way to do it?
BlueJ has a tool which makes the Javadoc, but BlueJ ignore private methods.
Is just a convention? If it's a convention, I don't understand why, they ignore "internal" methods, they are useful too -.-*

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

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

发布评论

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

评论(3

月牙弯弯 2024-12-31 18:13:37

此链接表明 BlueJ 将仅生成 JavaDocs公共方法和类。
具体来说:

您的输出将仅包含有关公共方法和变量的信息

但是,根据此 错误报告 链接到 Andrew Thompson 的回答,看来这已在版本中修复BlueJ 的 1.1.5。事实上,根据 BlueJ 参考手册第 9.8 节,您通过编辑 doctool.options 属性,可以准确指定运行 JavaDoc 工具时使用的选项。

似乎有 3 个属性控制文档生成的行为:

  • doctool.command:控制用于生成文档的命令,默认设置为 javadoc
  • doctool.outputdir:控制生成的文档的保存位置,默认设置为doc
  • doctool.options:控制传递给命令的其他命令行选项由指定javadoc.command,默认设置为 -author –version –nodeprecated –package。请注意,通过将 -package 替换为 -private,您可以记录所有方法。

一般来说,由于 JavaDoc 工具是一个命令行程序,您可以简单地从命令行自行调用它,如下所示:

$ javadoc -d \path\to\output\folder -sourcepath \path\to\source\folder -private

注意,此命令假定 javadoc 包含在您的 PATH 环境变量中,这通常是大多数 java 安装中的情况。

  • -d 选项给出所需的输出目录
  • -sourcepath 选项告诉 JavaDoc 工具在哪里可以找到要记录的源代码
  • -private 选项告诉 JavaDoc 工具为所有类、成员和方法创建文档(因为 private 是最受限制的可见性)

控制 JavaDoc 将记录的成员的选项的完整列表是:

  • -public - 显示只有公共类和成员。
  • -protected - 仅显示受保护的公共类和成员。这是默认设置。
  • -package - 仅显示包、受保护和公共类和成员。
  • -private - 显示所有类和成员。

(取自 JavaDoc 文档< /a>)

编辑 0:
更新了答案以纳入 Andrew Thompson 揭示的新信息

This link suggests that BlueJ will only generate JavaDocs for public methods and classes.
Specifically:

your output will only contain information about public methods and variables

However, according to this bug report linked to in Andrew Thompson's answer, it appears this has been fixed in version 1.1.5 of BlueJ. In fact, according to section 9.8 of the BlueJ Reference Manual, you can specify exactly what options to use when running the JavaDoc tool by editing the doctool.options property.

There appear to be 3 properties that control the behaviour of documentation generation:

  • doctool.command: controls what command is used to generate documentation, and by default is set to javadoc
  • doctool.outputdir: controls where generated documentation is saved, and by default is set to doc
  • doctool.options: controls other command line options passed to the command specified by javadoc.command, and by default is set to -author –version –nodeprecated –package. Note, that by replacing -package with -private you can document all methods.

In general, since the JavaDoc tool is a command line program, you can simply call it yourself from the command line with something like this:

$ javadoc -d \path\to\output\folder -sourcepath \path\to\source\folder -private

Note, this command assumes that the javadoc is included in your PATH environment variable, which is usually the case in most java installations.

  • The -d option gives the desired output directory
  • The -sourcepath option tells the JavaDoc tool where to find the source code to document
  • The -private option tells the JavaDoc tool to create documentation for all classes, members, and methods (as private is the most restricted visibility)

The full list of options that control the members that JavaDoc will document is:

  • -public - Shows only public classes and members.
  • -protected - Shows only protected and public classes and members. This is the default.
  • -package - Shows only package, protected, and public classes and members.
  • -private - Shows all classes and members.

(Taken from the JavaDoc Documentation)

EDIT 0:
Updated answer to incorporate new information brought to light by Andrew Thompson

转瞬即逝 2024-12-31 18:13:37

一般来说,按照惯例,人们不会将私有方法放入 Javadoc 中,因为 Javadoc 是供使用您的代码的人使用的。由于他们无法访问私有方法,因此为这些受众记录它们是没有意义的。

但是,javadoc 工具有一个标志可以启用此功能:

javadoc -private

将在 Javadoc 中生成私有方法。我不确定 BlueJ 如何处理这个问题,但也许你可以传递一个标志或其他东西。

Generally by convention people do not put private methods in Javadoc because Javadoc is meant to be for somebody consuming your code. Since they can't access private methods there's no sense in documenting them for that audience.

However, the javadoc tool has a flag to enable this:

javadoc -private

Will generate private methods in your Javadoc. I'm not sure how BlueJ works with this, but maybe you can pass in a flag or something.

凉月流沐 2024-12-31 18:13:37

已接受答案中的链接来自 2001 年写的一篇文章。自那以后发生了很多变化。

EG 搜索“bluej+javadocs”的前 5 个左右链接,其中包含一个提到 bug 报告的链接 允许在 javadoc 中包含私有方法。描述中提到:

使 javadoc 参数可由用户定义(在 bluej.defs 中),以便用户可以选择在文档中包含私有方法

还提到:

Resolution:     FIXED 

注意:我不使用 BlueJ,但当我听到令人难以置信的答案时,不得不继续寻找主流的 IDE 没有能力提供如此简单的配置。

The link in the accepted answer is from an article written in 2001. A lot has changed since then.

E.G. Hunting down through the top 5 or so links for 'bluej+javadocs' includes a link to something that mentions the bug report to allow inclusion of private methods in javadoc. The description mentions:

make javadoc parameters user definable (in bluej.defs) so that users have to option to include private methods in the documentation

Is also mentions:

Resolution:     FIXED 

Note: I don't use BlueJ, but had to go on a hunt when I heard the incredible answer that a major IDE has no ability to offer configuration of such a simple thing.

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