From 1ada27414d66e58b19e20a968834356e81dd26b2 Mon Sep 17 00:00:00 2001 From: vmishenev Date: Tue, 21 Sep 2021 21:38:44 +0300 Subject: Fix link to javadoc enum entry (#2131) --- .../javadoc/JavadocExternalLocationProvider.kt | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'plugins/base/src/main/kotlin') diff --git a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt index f1a32cb4..84445d2a 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt @@ -2,8 +2,7 @@ package org.jetbrains.dokka.base.resolvers.external.javadoc import org.jetbrains.dokka.base.resolvers.external.DefaultExternalLocationProvider import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation -import org.jetbrains.dokka.links.Callable -import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.links.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.utilities.htmlEscape @@ -30,8 +29,21 @@ open class JavadocExternalLocationProvider( if (classNames == null) { return "$docWithModule$packageLink/package-summary$extension".htmlEscape() } - val classLink = - if (packageLink == null) "${classNames}$extension" else "$packageLink/${classNames}$extension" + + // in Kotlin DRI of enum entry is not callable + if (DRIExtraContainer(extra)[EnumEntryDRIExtra] != null) { + val (classSplit, enumEntityAnchor) = if (callable == null) { + val lastIndex = classNames?.lastIndexOf(".") ?: 0 + classNames?.substring(0, lastIndex) to classNames?.substring(lastIndex + 1) + } else + classNames to callable?.name + + val classLink = + if (packageLink == null) "${classSplit}$extension" else "$packageLink/${classSplit}$extension" + return "$docWithModule$classLink#$enumEntityAnchor".htmlEscape() + } + + val classLink = if (packageLink == null) "${classNames}$extension" else "$packageLink/${classNames}$extension" val callableChecked = callable ?: return "$docWithModule$classLink".htmlEscape() return ("$docWithModule$classLink#" + anchorPart(callableChecked)).htmlEscape() -- cgit