Javadoc如何处理Java 9中模块的可见性? [英] How does the Javadoc deal with the visibility of modules in Java 9?
问题描述
Javadoc工具基于辅助功能修饰符生成文档。默认情况下,它记录所有 public
和 protected
类,字段和方法。可以使用以下选项更改此内容:
The Javadoc tool generates documentation based on the accessibility modifier. By default, it document all public
and protected
classes, fields and methods. This can be changed with the following options:
-public
仅显示公共课程和成员。
-public
Shows only public classes and members.
-protected
仅显示受保护的公共类和成员。这是默认值。
-protected
Shows only protected and public classes and members. This is the default.
-package
仅显示包,受保护和公共类及成员。
-package
Shows only package, protected, and public classes and members.
-private
显示所有类和成员。
-private
Shows all classes and members.
Java 9引入了概念模块和项目Jigsaw将其应用于现有的JDK。 Mark Reinhold的演讲(关于模块的系列讲座中的第3篇)展示了如何 public
修饰符现在具有不同的可访问级别,具体取决于模块的可见性(通过 exports
):
Java 9 introduces the concept of modules, and project Jigsaw applies it to the existing JDK. A talk by Mark Reinhold (3rd in a series of talks about modules) shows how the public
modifier now has different levels of accessibility, depending on the visibility of the module (via exports
):
- 向所有人公开
- 公开但仅限于特定模块
- 仅在模块内公开
由于现在并非所有公共成员都可以访问,因此会减少感觉继续使用相同的Javadoc生成方案。只有那些暴露在足够水平的成员才应该被记录下来。
Since now not all public members are accessible, it would make less sense to continue with the same Javadoc generation scheme. Only members which are exposed with a "sufficient" level should be documented.
是否可以识别Javadoc模块?除了上面的命令选项还有处理额外曝光层的命令选项吗?对于仅暴露于特定模块的公共成员,Javadoc是否列出这些,如
Is the Javadoc module-aware? Are there command options in addition to the ones above to handle the extra exposure layer? For public members which are exposed only to specific modules, does the Javadoc list these, as in
public <module1, module2> static void getDefaultThing()
?
推荐答案
javadoc具有新选项,允许您选择在模块,包,类型和成员级别记录哪些项目。使用EA版本的JDK 9,寻找新的 - 模块
, - show - *
选项,以及 - expand-requires
选项。
javadoc has new options that allow you to select which items are documented at the module, package, type and member level. Using an EA version of JDK 9, look for new --module
, --show-*
options, and --expand-requires
options.
现有选项 -public
, -protected
, -package
, -private
选项已根据新的 - show - *
选项重新定义,但仍需要更新其命令行帮助。
The existing options -public
, -protected
, -package
, -private
options have been redefined in terms of the new --show-*
options, although their command line help still needs to be updated.
方便花哨的转换表是:
-public
--show-module-contents api --show-packages exported --show-types public --show-members public
-protected (the long-standing default)
--show-module-contents api --show-packages exported --show-types protected --show-members protected
-package
--show-module-contents all --show-packages all --show-types package --show-members package
-private
--show-module-contents all --show-packages all --show-types private --show-members private
一般情况下,继续使用默认值为API用户生成文档,也许使用 -package
或 -private
为API的开发人员生成文档。要获得更精细的控制,请使用基础 - show - *
选项。
In general, continue to use the default to generate documentation for users of an API, and maybe use -package
or -private
to generate documentation for the developers of an API. For more fine-grain control, use the underlying --show-*
options.
这篇关于Javadoc如何处理Java 9中模块的可见性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!