RFR: JDK-8275788: Create code element with suitable attributes for code snippets

Pavel Rappo prappo at openjdk.java.net
Fri Oct 29 11:05:09 UTC 2021


On Fri, 29 Oct 2021 08:07:46 GMT, Hannes Wallnöfer <hannesw at openjdk.org> wrote:

>> src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/SnippetTaglet.java line 336:
>> 
>>> 334:             case ".scala", ".sc"                     -> "scala";
>>> 335:             case ".sh"                               -> "bash";
>>> 336:             case ".tex"                              -> "latex";
>> 
>> My initial reaction to this is that we should not bake this list in its current form in javadoc. I might be okay with just two cases: `.java` and `.properties`. Perhaps we could provide a way for users to configure any mappings beyond those two externally.
>
> Remember it's just a convenience/default mapping to create a language attribute without explicitly setting it. File extensions do not change over night, so I think the only risk here is missing out on some newly popular language or carrying some obsolete language that nobody will use (well I guess latex may fall in that category :)
> 
> I thought about (adding a comment about) making the mapping configurable, but I think any such mechanism would be much more complicated than just adding a "lang" attribute to your snippets.
> 
> I also thought about keeping the list minimal, but then it's just a little nod at anyone who may be using one of these languages.

Separately. After b97ea5b, the CI (test/langtools/tools/javac/NoStringToLower.java) complains about that `switch` using String.toLowerCase without explicit locale. We have multiple options here (should we clean that up in a separate PR?):

- Specify the locale (`Locale.US`) (sometimes we specify Locale.ROOT)
- Use jdk.javadoc.internal.doclets.toolkit.util.Utils.toLowerCase
- Use com.sun.tools.javac.util.StringUtils.toLowerCase

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

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


More information about the javadoc-dev mailing list