JDK-8195795 : Organize output files by module/package, not just package
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javadoc(tool)
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-01-19
  • Updated: 2019-01-16
  • Resolved: 2018-02-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11
11 b01Fixed
Related Reports
CSR :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
When generating the documentation for a series of modules, the pages for the packages and classes in that module are organized in a "traditional" package hierarchy, without any appearance of the module-name in the file path.  In addition, any module-specific files are named in the form <module-name>-<page-kind>.html.

This leads to a very cluttered top-level directory, and worse, it allows the possibility of files for one module overwriting some of the files for a different module, in the case when both modules contain a like-named package. While that may be uncommon, it is not disallowed, because javadoc does not have equivalent to the constraints on modules being analyzed by the compiler (javac) and runtime.

A better organization would be to have a top-level directory per module, and to create the package-hierarchy for the types in the module as a directory tree under the top-level module directory.  Module-specific files, like the module summary page then become <module-name>/<page-kind>.html instead of <module-name>-<page-kind>.html.

For the most part, this change will be transparent to the authors writing doc-comments, because for the most part, the links are either generated by the doclet itself, to link to other program elements, or the links are generated in response to `@see` and `{@link}` tags in the documentation comment, which just abstractly reference program elements, which any details of the file layout.  The one other case is when an author writes an explicit `<a href=...>` in a doc comment. The two reasons to use such links is (1) to reference user-written anchors `<a id=...>` within the documentation and (2) to reference auxiliary files, such as in `doc-files` subdirectories.  We do not currently support top-level `doc-files` in a module, because of the issues being presented here. While we could support them in the current layout scheme, it would be better to settle on the preferred layout scheme before we open up the ability to use top-level `doc-files` in a module. (See JDK-8194553)

Because of the potential to negatively impact user-written  `<a href=...>` links, we should provide a temporary option to have the doclet revert to its current package-oriented behavior. Using such an option should generate a warning, advising authors to update their docs to accomodate the module-oriented layout.

Comments
Early indications are that adding the module directory into the path will increase the overall character-size of the docs by about 5%, because of the current simple <path-to-root>/<path-to-target> scheme for relative URLs within the doc bundle. See the related work JDK-8195796 to simplify relative URLs to largely eliminate that cost, and still reduce the overall size of the docs.
19-01-2018