RFR: 8342808: Javadoc should add whitespace between type parameters

Jonathan Gibbons jjg at openjdk.org
Thu Oct 31 17:38:30 UTC 2024


On Tue, 29 Oct 2024 11:14:54 GMT, Nizar Benalla <nbenalla at openjdk.org> wrote:

> Please review this patch to render javadocs as `<K, V, T>` rather than `<K,V,T>` to match naming conventions and make the rendered output slighly nicer to read.
> 
> Passes langtool tests.
> 
> The[ generated docs](https://cr.openjdk.org/~nbenalla/GeneratedDocs/TypeParams/docs/api/index.html) only includes `java.base/lang`, `java.base/util` and `java.compiler/javax`

It might be interesting to audit the JDK codebase for prevailing patterns in source code.  While regexes are not great for parsing, they may be good enough for a reasonably good analysis.
For example, as a start, look for
* `<[^> ]+>` -- instances of type parameters or arguments with no space (yes, it doesn't, do nested types, but it's good enough)
* `<[^>]+ [^>]+>` --  instances of type parameters or arguments with at least one space
* `((class|interface) [A-Za-z0-9]+)|public|static) *<[^> ]+>` -- instances of type parameters with no space
* `((class|interface) [A-Za-z0-9]+)|public|static) <[^>]+ [^>]+>` -- instances of type parameters at least one space

The regexes are just a suggestion and may need refinement.  The intent is to catch character sequences between `<` and `>` , and to further filter those that look like generic type or method declarations


That being said, the info would just be informative, and not the final criterion. It might be interesting to look at other more definitive references, such as examples in JLS.

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

PR Comment: https://git.openjdk.org/jdk/pull/21759#issuecomment-2450450377


More information about the javadoc-dev mailing list