RFR: JDK-8310118: Resource files should be moved to appropriate directories

Jonathan Gibbons jjg at openjdk.org
Mon Aug 7 20:55:29 UTC 2023


On Mon, 7 Aug 2023 14:42:08 GMT, Hannes Wallnöfer <hannesw at openjdk.org> wrote:

> Please review a change to rename the directories previoiusly called `resources` and `script-dir` in `javadoc`-generated documentation to `resource-files` and `script-files`, and consistently moving all files that are not related to the documented code into these directories. This includes scripts and stylesheets added via command line options.
> 
> In the process I cleaned up the code which copies scripts and resources. I added a new private `HtmlDoclet.copyResource` method which takes care of resolving resources relative to the `doclet.formats.html` or `doclet.toolkit` packages and determines whether a resource needs localization based on the file extension of the source resource. The new code will also throw an exception if the source resource does not exist, while previously `DocFile.copyResource` returned silently. 
> 
> Another unrelated cleanup was to remove a bunch of jQuery-UI image files in a resource subdirectory that were not used anymore.
> 
> In addition to make sure all tests pass I did extensive manual testing of the generated docs to make sure all scripts and resources are loaded correctly. This includes the `@import` statement for `resources/fonts/dejavu.css` in the default stylesheet, which is now changed to `fonts/dejavu.css` assuming the `fonts` directory will now be located in `resource-files`.

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java line 431:

> 429:         // If not found try toolkit resources
> 430:         if (resourceURL == null) {
> 431:             resourceURL = BaseConfiguration.class.getResource(resourcePath.getPath());

It always seemed wrong (a bug) that `stylesheet.css` was down in the `toolkit` world.
It is also possible to reason that `script.js` should not be in the `toolkit` world either.
Maybe this would be a good time to move those files into the `formats/html` world, as
well as the two `.svg` files, so that all resource files that need to be copied into the 
generated API directories are in the `formats/html` world.

In other words, we might be able to avoid lines 430-432

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15180#discussion_r1286374268


More information about the javadoc-dev mailing list