Kotlin / dokka

API documentation engine for Kotlin
https://kotl.in/dokka
Apache License 2.0
3.41k stars 403 forks source link

HTML hyperlink inside @see in Javadoc in Java files fails to render properly #3703

Open jbartok opened 2 months ago

jbartok commented 2 months ago

Describe the bug Following line is not interpreted correctly when in Javadoc in a Java file. Works however properly in Javadoc in Kotlin files:

@see <a href="https://docs.gradle.org/current/userguide/configuration_cache.html">Configuration Cache</a>

See example here (at the end of the class documentation, after the "See also: Provider Factory" part), generated from these sources.

Screenshots

image

Dokka configuration Generation done via the Dokkatoo plugin 2.3.1, based on Dokka 1.9.20.

owengray-google commented 1 month ago

The kdoc spec for see tags https://kotlinlang.org/docs/kotlin-doc.html#see-identifier says that it only supports links to classes and methods, not URL literals.
I think kdoc should have parity with javadoc (https://docs.oracle.com/en/java/javase/19/docs/specs/javadoc/doc-comment-spec.html#see), which it sounds like it already may in dokka--I think that kdoc spec page should be updated.

whyoleg commented 1 month ago

Hey, thanks for reporting this! During the investigation if it's possible to somehow easy fix it I found several inconsistencies in behaviour of Dokka with KDoc and JavaDoc @see tag: KDoc:

JavaDoc:

Dokka implementation details:

Possible solutions:

  1. (ad-hoc) add a parameter externalAddress: String? and fill it only in case of JavaDoc - then we will need to parse this mini html of a link in javadoc to get the label and the link
  2. (ad-hoc) do not add a parameter. If there is html link there, parse it in DocTag and then it will be displayed not in the normal way on the left - but on the right. If we will add additional logic to show it on the left, we may possible support even more undefined behaviours in this regard
  3. do nothing now, but resolve all of the issues above, both for KDoc spec vs IDEA vs Dokka inconsistencies and properly support @see tag for both KDoc and JavaDoc consistently in future during KDoc spec design refinements (which are currently started to be real, e.g https://github.com/Kotlin/KEEP/issues/385)

Keeping in mind all this, we don't really want to introduce any more fragile ad-hoc solutions with no clear specification of how it should work having in mind that we have other more important issues to resolve even with Kotlin-only sources with bigger impact. So we would like to stick with the solution number three. Hope this is understandable.