RFR: 8352740: Introduce new factory method HtmlTree.IMG [v3]

Jonathan Gibbons jjg at openjdk.org
Tue Mar 25 18:44:16 UTC 2025


On Tue, 25 Mar 2025 12:21:29 GMT, Nizar Benalla <nbenalla at openjdk.org> wrote:

>> Please review this small patch to add a new factory method `HtmlTree IMG(DocPath src, String alt)`, to provide a convenient way to reliably create valid tree nodes.
>> 
>> Previously, all uses of `HtmlTag.IMG` followed a similar pattern :
>> 
>> HtmlTree.of(HtmlTag.IMG)
>>                         .put(HtmlAttr.SRC, docpath)
>>                         .put(HtmlAttr.ALT, alt)
>> 
>> 
>> However, it was easy to forget to add the required "alt" attribute. Those have been replaced by the new factory method.
>> 
>> No tests are required as part of this change.
>> 
>> TIA
>
> Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision:
> 
>   feedback: document params of the factory method.

Marked as reviewed by jjg (Reviewer).

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/SnippetTaglet.java line 199:

> 197:                         .add(HtmlTree.IMG(pathToRoot.resolve(DocPaths.RESOURCE_FILES)
> 198:                                         .resolve(DocPaths.CLIPBOARD_SVG),
> 199:                                 copySnippetText))

Not for this PR, but another tiny cleanup would be to add an overload to `DocPaths.resolve` that takes multiple arguments to be applied (resolve'd) sequentially

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

PR Review: https://git.openjdk.org/jdk/pull/24204#pullrequestreview-2714844251
PR Review Comment: https://git.openjdk.org/jdk/pull/24204#discussion_r2012734109


More information about the javadoc-dev mailing list