diff options
Diffstat (limited to 'plugins/base/src')
3 files changed, 38 insertions, 2 deletions
diff --git a/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt index c645157a..45440d2b 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt @@ -15,18 +15,21 @@ open class Dokka010ExternalLocationProvider( val docURL = externalDocumentation.documentationURL.toString().removeSuffix("/") + "/" val fqName = listOfNotNull(dri.packageName.takeIf { it?.isNotBlank() == true }, - dri.classNames.takeIf { it?.isNotBlank() == true }).joinToString(".") + dri.classNames.takeIf { it?.isNotBlank() == true }?.removeCompanion()).joinToString(".") val relocationId = fqName.let { if (dri.callable != null) it + "$" + dri.callable!!.toOldString() else it } externalDocumentation.packageList.locations[relocationId]?.let { path -> return "$docURL$path" } - val classNamesChecked = dri.classNames ?: return "$docURL${dri.packageName ?: ""}/index$extension" + val classNamesChecked = dri.classNames?.removeCompanion() + ?: return "$docURL${dri.packageName ?: ""}/index$extension" + val classLink = (listOfNotNull(dri.packageName) + classNamesChecked.split('.')) .joinToString("/", transform = ::identifierToFilename) val callableChecked = dri.callable ?: return "$docURL$classLink/index$extension" return "$docURL$classLink/" + identifierToFilename(callableChecked.name) + extension } + private fun String.removeCompanion() = removeSuffix(".Companion") private fun Callable.toOldString() = name + params.joinToString(", ", "(", ")") + (receiver?.let { "#$it" } ?: "") } diff --git a/plugins/base/src/test/kotlin/locationProvider/Dokka010ExternalLocationProviderTest.kt b/plugins/base/src/test/kotlin/locationProvider/Dokka010ExternalLocationProviderTest.kt index 1a2a45d7..31ffa0b3 100644 --- a/plugins/base/src/test/kotlin/locationProvider/Dokka010ExternalLocationProviderTest.kt +++ b/plugins/base/src/test/kotlin/locationProvider/Dokka010ExternalLocationProviderTest.kt @@ -71,4 +71,36 @@ class Dokka010ExternalLocationProviderTest : AbstractCoreTest() { assertEquals("$kotlinLang/kotlin/java.math.-big-decimal/minus.html", locationProvider.resolve(dri)) } + + @Test + fun `#1268 companion part should be stripped`() { + val locationProvider = getTestLocationProvider() + val dri = DRI( + "kotlin", + "Int.Companion", + Callable( + "MIN_VALUE", + null, + emptyList() + ) + ) + + assertEquals("$kotlinLang/kotlin/-int/-m-i-n_-v-a-l-u-e.html", locationProvider.resolve(dri)) + } + + @Test + fun `companion part should be stripped in relocations`() { + val locationProvider = getTestLocationProvider() + val dri = DRI( + "kotlin", + "Int.Companion", + Callable( + "MAX_VALUE", + null, + emptyList() + ) + ) + + assertEquals("$kotlinLang/kotlin/-int/max-value.html", locationProvider.resolve(dri)) + } } diff --git a/plugins/base/src/test/resources/locationProvider/old-package-list b/plugins/base/src/test/resources/locationProvider/old-package-list index e2dfc92a..d05b4535 100644 --- a/plugins/base/src/test/resources/locationProvider/old-package-list +++ b/plugins/base/src/test/resources/locationProvider/old-package-list @@ -2,6 +2,7 @@ $dokka.format:kotlin-website-html $dokka.linkExtension:html $dokka.location:kotlin.text.StringBuilderkotlin.relocated.text/-string-builder/index.html $dokka.location:kotlin$minus(java.math.BigDecimal, java.math.BigDecimal)kotlin/java.math.-big-decimal/minus.html +$dokka.location:kotlin.Int$MAX_VALUE()kotlin/-int/max-value.html kotlin kotlin.text kotlin.reflect |