diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2020-08-21 12:51:34 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-08-21 18:38:10 +0200 |
commit | 8b0b4604f834ac5edd4f9569647fdfd0a966e768 (patch) | |
tree | ea22c2da1a764c1b296a4df70d69e63d61c9377b /plugins/base/src/main/kotlin/resolvers/external | |
parent | f2635289b1923866843e1dd47423bd6ca74c2cb1 (diff) | |
download | dokka-8b0b4604f834ac5edd4f9569647fdfd0a966e768.tar.gz dokka-8b0b4604f834ac5edd4f9569647fdfd0a966e768.tar.bz2 dokka-8b0b4604f834ac5edd4f9569647fdfd0a966e768.zip |
Fix linking to declarations in companion objects in old dokka formats
Diffstat (limited to 'plugins/base/src/main/kotlin/resolvers/external')
-rw-r--r-- | plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt | 7 |
1 files changed, 5 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" } ?: "") } |