Linking to anchors in the same class

Jonathan Gibbons jonathan.gibbons at oracle.com
Thu Feb 15 18:35:37 UTC 2024


Nir,

Thank you for your question.  It may be that there is a bug, or at 
least, a lack of tests, in this area.

In general, you need to give text for the link, since (unlike for 
program elements) javadoc cannot infer the string for itself. Iit 
doesn't go looking for headings and ids.

You might try  `@see Chronus##time-heading my-text` or failing that `<a 
href="Chronus.html##time-heading">my-text</a>

For our part, we should make sure that we have tests for this situation 
and/or clarify the spec if that is needed.

-- Jon

On 2/15/24 9:22 AM, Nir Lisker wrote:
> Hi,
>
> I have a question after reading 
> https://bugs.openjdk.org/browse/JDK-8294195. If I have a class 
> Chronus.java with a heading in its class javadoc:
>
> <h2>Time</h2>
>
> then an anchor Chronus.html#time-heading is auto-generated. How do I 
> link to this anchor from within the class using @see and @link? I have 
> tried
> @see ##time-heading
> @see Chronus.html##time-heading
> @see Chronus##Chronus.html#time-heading
>
> None of which work. What is the correct syntax?
>
> Thanks,
> Nir
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/javadoc-dev/attachments/20240215/17902f26/attachment-0001.htm>


More information about the javadoc-dev mailing list