diff options
author | Andrzej Ratajczak <32793002+BarkingBad@users.noreply.github.com> | 2022-01-27 10:39:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-27 12:39:56 +0300 |
commit | 7c44db1ef0075e2b80a4723e0747bbf57c32e775 (patch) | |
tree | d20079f969fbb977603852ef4ea2234e54851f98 /plugins/base/src/main | |
parent | d884fa7ce3088ac9ae0ca1bbad70e698888610fa (diff) | |
download | dokka-7c44db1ef0075e2b80a4723e0747bbf57c32e775.tar.gz dokka-7c44db1ef0075e2b80a4723e0747bbf57c32e775.tar.bz2 dokka-7c44db1ef0075e2b80a4723e0747bbf57c32e775.zip |
Fix resolving DRIs of Enum Entries (#2305)
* Fix resolving DRIs of Enum Entries
* Unify DRIs for Kotlin and Java enums. Add EnumEntry linking tests
* Updates EnumEntry extras in documentable translators
* Fix tests
* Apply requested changes
* Apply requested changes
Diffstat (limited to 'plugins/base/src/main')
4 files changed, 8 insertions, 11 deletions
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 84445d2a..a1f1542d 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt @@ -30,13 +30,10 @@ open class JavadocExternalLocationProvider( return "$docWithModule$packageLink/package-summary$extension".htmlEscape() } - // 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 + val lastIndex = classNames?.lastIndexOf(".") ?: 0 + val (classSplit, enumEntityAnchor) = 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" diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index e996a865..6078b54d 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -317,7 +317,7 @@ private class DokkaDescriptorVisitor( val classlikes = async { descriptorsWithKind.classlikes.visitClasslikes(driWithPlatform) } DEnumEntry( - dri = driWithPlatform.dri, + dri = driWithPlatform.dri.withEnumEntryExtra(), name = descriptor.name.asString(), documentation = descriptor.resolveDescriptorData(), functions = functions.await(), diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index e7028ef0..79b4798c 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -21,11 +21,11 @@ import org.jetbrains.dokka.base.translators.isDirectlyAnException import org.jetbrains.dokka.base.translators.psi.parsers.JavaDocumentationParser import org.jetbrains.dokka.base.translators.psi.parsers.JavadocParser import org.jetbrains.dokka.base.translators.unquotedValue -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.links.nextTarget -import org.jetbrains.dokka.links.withClass +import org.jetbrains.dokka.links.* import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.AnnotationTarget +import org.jetbrains.dokka.model.Nullable +import org.jetbrains.dokka.model.TypeConstructor import org.jetbrains.dokka.model.doc.DocumentationNode import org.jetbrains.dokka.model.doc.Param import org.jetbrains.dokka.model.properties.PropertyContainer @@ -269,7 +269,7 @@ class DefaultPsiToDocumentableTranslator( name.orEmpty(), fields.filterIsInstance<PsiEnumConstant>().map { entry -> DEnumEntry( - dri.withClass(entry.name), + dri.withClass(entry.name).withEnumEntryExtra(), entry.name, javadocParser.parseDocumentation(entry).toSourceSetDependent(), null, diff --git a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt index f9f591b2..fd8a49c8 100644 --- a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt +++ b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt @@ -326,7 +326,7 @@ class JavadocParser( dri.toString() } ?: UNRESOLVED_PSI_ELEMENT - return """<a data-dri="$dri">${label.ifBlank{ defaultLabel().text }}</a>""" + return """<a data-dri="${dri.htmlEscape()}">${label.ifBlank{ defaultLabel().text }}</a>""" } private fun convertInlineDocTag( |