diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2023-11-10 11:46:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-10 11:46:54 +0100 |
commit | 8e5c63d035ef44a269b8c43430f43f5c8eebfb63 (patch) | |
tree | 1b915207b2b9f61951ddbf0ff2e687efd053d555 /plugins/base/src/main/kotlin/resolvers/external | |
parent | a44efd4ba0c2e4ab921ff75e0f53fc9335aa79db (diff) | |
download | dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.gz dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.bz2 dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.zip |
Restructure the project to utilize included builds (#3174)
* Refactor and simplify artifact publishing
* Update Gradle to 8.4
* Refactor and simplify convention plugins and build scripts
Fixes #3132
---------
Co-authored-by: Adam <897017+aSemy@users.noreply.github.com>
Co-authored-by: Oleg Yukhnevich <whyoleg@gmail.com>
Diffstat (limited to 'plugins/base/src/main/kotlin/resolvers/external')
9 files changed, 0 insertions, 289 deletions
diff --git a/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt deleted file mode 100644 index 32825303..00000000 --- a/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.base.resolvers.external - -import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProvider.Companion.identifierToFilename -import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.plugability.DokkaContext - -public open class DefaultExternalLocationProvider( - public val externalDocumentation: ExternalDocumentation, - public val extension: String, - public val dokkaContext: DokkaContext -) : ExternalLocationProvider { - public val docURL: String = externalDocumentation.documentationURL.toString().removeSuffix("/") + "/" - - override fun resolve(dri: DRI): String? { - externalDocumentation.packageList.locations[dri.toString()]?.let { path -> return "$docURL$path" } - - if (dri.packageName !in externalDocumentation.packageList.packages) - return null - - return dri.constructPath() - } - - protected open fun DRI.constructPath(): String { - val modulePart = packageName?.let { packageName -> - externalDocumentation.packageList.moduleFor(packageName)?.let { - if (it.isNotBlank()) - "$it/" - else - "" - } - }.orEmpty() - - val docWithModule = docURL + modulePart - val classNamesChecked = classNames ?: return "$docWithModule${packageName ?: ""}/index$extension" - val classLink = (listOfNotNull(packageName) + classNamesChecked.split('.')) - .joinToString("/", transform = ::identifierToFilename) - - val fileName = callable?.let { identifierToFilename(it.name) } ?: "index" - return "$docWithModule$classLink/$fileName$extension" - } -} diff --git a/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProviderFactory.kt deleted file mode 100644 index 09ddca01..00000000 --- a/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProviderFactory.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.base.resolvers.external - -import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat -import org.jetbrains.dokka.plugability.DokkaContext - -public class DefaultExternalLocationProviderFactory( - public val context: DokkaContext, -) : ExternalLocationProviderFactory by ExternalLocationProviderFactoryWithCache( - { doc -> - when (doc.packageList.linkFormat) { - RecognizedLinkFormat.KotlinWebsite, - RecognizedLinkFormat.KotlinWebsiteHtml, - RecognizedLinkFormat.DokkaOldHtml, - -> Dokka010ExternalLocationProvider(doc, ".html", context) - - RecognizedLinkFormat.DokkaHtml -> DefaultExternalLocationProvider(doc, ".html", context) - RecognizedLinkFormat.DokkaGFM, - RecognizedLinkFormat.DokkaJekyll, - -> DefaultExternalLocationProvider(doc, ".md", context) - - else -> null - } - } -) diff --git a/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt deleted file mode 100644 index f887c9bc..00000000 --- a/plugins/base/src/main/kotlin/resolvers/external/Dokka010ExternalLocationProvider.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.base.resolvers.external - -import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProvider.Companion.identifierToFilename -import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation -import org.jetbrains.dokka.links.Callable -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.plugability.DokkaContext - -public open class Dokka010ExternalLocationProvider( - public val externalDocumentation: ExternalDocumentation, - public val extension: String, - public val dokkaContext: DokkaContext -) : ExternalLocationProvider { - public val docURL: String = externalDocumentation.documentationURL.toString().removeSuffix("/") + "/" - - override fun resolve(dri: DRI): String? { - - val fqName = listOfNotNull( - dri.packageName.takeIf { it?.isNotBlank() == true }, - 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" } - - if (dri.packageName !in externalDocumentation.packageList.packages) - return null - - 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/main/kotlin/resolvers/external/ExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProvider.kt deleted file mode 100644 index 238b6342..00000000 --- a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProvider.kt +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.base.resolvers.external - -import org.jetbrains.dokka.links.DRI - -/** - * Provides the path to the page documenting a [DRI] in an external documentation source - */ -public fun interface ExternalLocationProvider { - /** - * @return Path to the page containing the [dri] or null if the path cannot be created - * (eg. when the package-list does not contain [dri]'s package) - */ - public fun resolve(dri: DRI): String? -} diff --git a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt deleted file mode 100644 index 952f4d51..00000000 --- a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.base.resolvers.external - -import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation - -public fun interface ExternalLocationProviderFactory { - public fun getExternalLocationProvider(doc: ExternalDocumentation): ExternalLocationProvider? -} diff --git a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactoryWithCache.kt b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactoryWithCache.kt deleted file mode 100644 index 0b56e174..00000000 --- a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactoryWithCache.kt +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.base.resolvers.external - -import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation -import java.util.concurrent.ConcurrentHashMap - -public class ExternalLocationProviderFactoryWithCache( - public val ext: ExternalLocationProviderFactory -) : ExternalLocationProviderFactory { - - private val locationProviders = ConcurrentHashMap<ExternalDocumentation, CacheWrapper>() - - override fun getExternalLocationProvider(doc: ExternalDocumentation): ExternalLocationProvider? = - locationProviders.getOrPut(doc) { CacheWrapper(ext.getExternalLocationProvider(doc)) }.provider - - private class CacheWrapper(val provider: ExternalLocationProvider?) -} - diff --git a/plugins/base/src/main/kotlin/resolvers/external/javadoc/AndroidExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/javadoc/AndroidExternalLocationProvider.kt deleted file mode 100644 index 8c18be0c..00000000 --- a/plugins/base/src/main/kotlin/resolvers/external/javadoc/AndroidExternalLocationProvider.kt +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.base.resolvers.external.javadoc - -import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation -import org.jetbrains.dokka.links.Callable -import org.jetbrains.dokka.plugability.DokkaContext - -public open class AndroidExternalLocationProvider( - externalDocumentation: ExternalDocumentation, - dokkaContext: DokkaContext -) : JavadocExternalLocationProvider(externalDocumentation, "", "", dokkaContext) { - - override fun anchorPart(callable: Callable): String = callable.name.toLowerCase() - -} diff --git a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt deleted file mode 100644 index 65ee0e02..00000000 --- a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -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.DRIExtraContainer -import org.jetbrains.dokka.links.EnumEntryDRIExtra -import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.utilities.htmlEscape - -public open class JavadocExternalLocationProvider( - externalDocumentation: ExternalDocumentation, - public val brackets: String, - public val separator: String, - dokkaContext: DokkaContext -) : DefaultExternalLocationProvider(externalDocumentation, ".html", dokkaContext) { - - override fun DRI.constructPath(): String { - val packageLink = packageName?.replace(".", "/") - val modulePart = packageName?.let { packageName -> - externalDocumentation.packageList.moduleFor(packageName)?.let { - if (it.isNotBlank()) - "$it/" - else - "" - } - }.orEmpty() - - val docWithModule = docURL + modulePart - - if (classNames == null) { - return "$docWithModule$packageLink/package-summary$extension".htmlEscape() - } - - if (DRIExtraContainer(extra)[EnumEntryDRIExtra] != null) { - val lastIndex = classNames?.lastIndexOf(".") ?: 0 - val (classSplit, enumEntityAnchor) = - classNames?.substring(0, lastIndex) to classNames?.substring(lastIndex + 1) - - 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() - } - - protected open fun anchorPart(callable: Callable): String { - return callable.name + - "${brackets.first()}" + - callable.params.joinToString(separator) + - "${brackets.last()}" - } -} diff --git a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProviderFactory.kt deleted file mode 100644 index dc184e49..00000000 --- a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProviderFactory.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.base.resolvers.external.javadoc - -import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.androidSdk -import org.jetbrains.dokka.androidX -import org.jetbrains.dokka.base.resolvers.external.ExternalLocationProviderFactory -import org.jetbrains.dokka.base.resolvers.external.ExternalLocationProviderFactoryWithCache -import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat -import org.jetbrains.dokka.plugability.DokkaContext - -public class JavadocExternalLocationProviderFactory( - public val context: DokkaContext, -) : ExternalLocationProviderFactory by ExternalLocationProviderFactoryWithCache( - { doc -> - when (doc.packageList.url) { - DokkaConfiguration.ExternalDocumentationLink.androidX().packageListUrl, - DokkaConfiguration.ExternalDocumentationLink.androidSdk().packageListUrl, - -> - AndroidExternalLocationProvider(doc, context) - - else -> - when (doc.packageList.linkFormat) { - RecognizedLinkFormat.Javadoc1 -> - JavadocExternalLocationProvider(doc, "()", ", ", context) // Covers JDK 1 - 7 - RecognizedLinkFormat.Javadoc8 -> - JavadocExternalLocationProvider(doc, "--", "-", context) // Covers JDK 8 - 9 - RecognizedLinkFormat.Javadoc10, - RecognizedLinkFormat.DokkaJavadoc, - -> - JavadocExternalLocationProvider(doc, "()", ",", context) // Covers JDK 10 - else -> null - } - } - } -) |