RFR: JDK-8276964: Better indicate a snippet that could not be processed

Hannes Wallnöfer hannesw at openjdk.java.net
Fri Nov 26 17:04:21 UTC 2021


The primary purpose of this change is to make it easier to spot invalid snippets in generated documentation. 

This adds a new `Content invalidTagOutput(String summary, Optional<String> detail)` method that returns HTML to display the summary and optionally a detail message. The method is only used for snippet tags for now, but is generic and could be used for other invalid tags in the future. 

If the `detail` argument is empty or contains a blank string, a `<span>` element is returned containing the `summary` argument. If a detail argument is provided, a HTML5 `<details>` element is returned containing a `<summary>` element with the `summary` argument and a `<pre>` element containing the `details` argument. In both cases the returned element is styled with a thin border and a light red background.

In its current use the `detail` argument is always provided by the message of the `ParseException` or `BadSnippetException` that was thrown and caught. 

Example output is available here: http://cr.openjdk.java.net/~hannesw/8276964/api.01/snippet_errormessages/A.html

I added output checks to some but not all of the negative tests. In addition I slightly reformatted `TestSnippetTag.java` to add indentation to some previously unindeted text blocks.

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

Commit messages:
 - Remove trailing whitespace
 - JDK-8276964: Better indicate a snippet that could not be processed

Changes: https://git.openjdk.java.net/jdk/pull/6579/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=6579&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8276964
  Stats: 231 lines in 8 files changed: 102 ins; 2 del; 127 mod
  Patch: https://git.openjdk.java.net/jdk/pull/6579.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/6579/head:pull/6579

PR: https://git.openjdk.java.net/jdk/pull/6579


More information about the javadoc-dev mailing list