RFR: 8348282: Add option for syntax highlighting in javadoc snippets [v4]

Hannes Wallnöfer hannesw at openjdk.org
Thu Apr 10 13:05:36 UTC 2025


On Wed, 9 Apr 2025 04:15:20 GMT, Hannes Wallnöfer <hannesw at openjdk.org> wrote:

>> Please review a change to add a `javadoc` option to enable syntax highlighting for code fragments in snippets and  `<pre><code>` tags. The new `--syntax-highlight` option uses the [highlight.js] JavaScript library and supports Java, Properties, XML, HTML and JSON. The option is enabled in the JDK API docs target, [generated output is available here](https://cr.openjdk.org/~hannesw/8348282/api.00/index.html).
>
> Hannes Wallnöfer has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Adjust color palette

Here's a selection of code fragments from the sample docs using syntax highlighting:

 - [Thread example](https://cr.openjdk.org/~hannesw/8348282/api.00/java.base/java/lang/Thread.html#snippet-java.lang.Thread1)
 - [Doclet example](https://cr.openjdk.org/~hannesw/8348282/api.00/jdk.javadoc/jdk/javadoc/doclet/package-summary.html#example-heading)
 - [PropertyResourceBundle](https://cr.openjdk.org/~hannesw/8348282/api.00/java.base/java/util/PropertyResourceBundle.html#snippet-java.util.PropertyResourceBundle1)
- [ListResourceBundle](https://cr.openjdk.org/~hannesw/8348282/api.00/java.base/java/util/ListResourceBundle.html#snippet-java.util.ListResourceBundle1)
- [ClassFile example](https://cr.openjdk.org/~hannesw/8348282/api.00/java.base/java/lang/classfile/attribute/package-summary.html#snippet-java.lang.classfile.attribute1)
- [MethodHandles example](https://cr.openjdk.org/~hannesw/8348282/api.00/java.base/java/lang/invoke/MethodHandles.html#snippet-collectArguments(java.lang.invoke.MethodHandle,int,java.lang.invoke.MethodHandle)1)

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

PR Comment: https://git.openjdk.org/jdk/pull/24417#issuecomment-2792716273


More information about the javadoc-dev mailing list