Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark utilities.* API as Dokka-internal #2937

Merged
merged 1 commit into from Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -43,4 +43,6 @@ dependencies {
// repetitive, but more declarative and clear), or some other solution.
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine")
// kotlin-test asserts for all projects
testImplementation(kotlin("test-junit"))
}
Expand Up @@ -11,15 +11,21 @@ plugins {

configureDokkaVersion()

val projectsWithoutOptInDependency = setOf(
":integration-tests", ":integration-tests:gradle", ":integration-tests:maven", ":integration-tests:cli")

tasks.withType<KotlinCompile>().configureEach {
// By path because Dokka has multiple projects with the same name (i.e. 'cli')
if (project.path in projectsWithoutOptInDependency) return@configureEach
compilerOptions {
freeCompilerArgs.addAll(
listOf(
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=org.jetbrains.dokka.InternalDokkaApi",
"-Xjsr305=strict",
"-Xskip-metadata-version-check",
// need 1.4 support, otherwise there might be problems with Gradle 6.x (it's bundling Kotlin 1.4)
"-Xsuppress-version-warnings"
"-Xsuppress-version-warnings",
)
)
allWarningsAsErrors.set(true)
Expand Down
3 changes: 1 addition & 2 deletions build.gradle.kts
@@ -1,4 +1,5 @@
import org.jetbrains.ValidatePublications
import org.jetbrains.kotlin.gradle.tasks.*
import org.jetbrains.publicationChannels

@Suppress("DSL_SCOPE_VIOLATION") // fixed in Gradle 8.1 https://github.com/gradle/gradle/pull/23639
Expand Down Expand Up @@ -50,7 +51,5 @@ apiValidation {
"gradle", // :integration-tests:gradle
"cli", // :integration-tests:cli
"maven", // integration-tests:maven

"test-utils", // :test-utils
)
}
1 change: 0 additions & 1 deletion core/api/core.api
Expand Up @@ -4580,7 +4580,6 @@ public final class org/jetbrains/dokka/utilities/DokkaConsoleLogger : org/jetbra
public fun debug (Ljava/lang/String;)V
public fun error (Ljava/lang/String;)V
public fun getErrorsCount ()I
public final fun getMinLevel ()Lorg/jetbrains/dokka/utilities/LoggingLevel;
public fun getWarningsCount ()I
public fun info (Ljava/lang/String;)V
public fun progress (Ljava/lang/String;)V
Expand Down
6 changes: 0 additions & 6 deletions core/build.gradle.kts
Expand Up @@ -40,12 +40,6 @@ tasks {
}
}

tasks.withType(KotlinCompile::class).all {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + listOf("-opt-in=org.jetbrains.dokka.InternalDokkaApi",)
}
}

registerDokkaArtifactPublication("dokkaCore") {
artifactId = "dokka-core"
}
2 changes: 1 addition & 1 deletion core/src/main/kotlin/utilities/DokkaLogging.kt
Expand Up @@ -39,7 +39,7 @@ fun interface MessageEmitter : (String) -> Unit {
}

class DokkaConsoleLogger(
val minLevel: LoggingLevel = LoggingLevel.PROGRESS,
private val minLevel: LoggingLevel = LoggingLevel.PROGRESS,
private val emitter: MessageEmitter = MessageEmitter.consoleEmitter
) : DokkaLogger {
private val warningsCounter = AtomicInteger()
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/kotlin/utilities/Html.kt
@@ -1,15 +1,19 @@
package org.jetbrains.dokka.utilities

import org.jetbrains.dokka.*
import java.net.URLEncoder


/**
* Replaces symbols reserved in HTML with their respective entities.
* Replaces & with &amp;, < with &lt; and > with &gt;
*/
@InternalDokkaApi
fun String.htmlEscape(): String = replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;").replace("\"", "&quot;")

@InternalDokkaApi
fun String.urlEncoded(): String = URLEncoder.encode(this, "UTF-8")

@InternalDokkaApi
fun String.formatToEndWithHtml() =
if (endsWith(".html") || contains(Regex("\\.html#"))) this else "$this.html"
7 changes: 4 additions & 3 deletions core/src/main/kotlin/utilities/ServiceLocator.kt
@@ -1,16 +1,20 @@
package org.jetbrains.dokka.utilities

import org.jetbrains.dokka.*
import java.io.File
import java.net.URISyntaxException
import java.net.URL
import java.util.*
import java.util.jar.JarFile
import java.util.zip.ZipEntry

@InternalDokkaApi
data class ServiceDescriptor(val name: String, val category: String, val description: String?, val className: String)

@InternalDokkaApi
class ServiceLookupException(message: String) : Exception(message)

@InternalDokkaApi
object ServiceLocator {
fun <T : Any> lookup(clazz: Class<T>, category: String, implementationName: String): T {
val descriptor = lookupDescriptor(category, implementationName)
Expand Down Expand Up @@ -81,9 +85,6 @@ object ServiceLocator {
}
}

inline fun <reified T : Any> ServiceLocator.lookup(category: String, implementationName: String): T = lookup(T::class.java, category, implementationName)
inline fun <reified T : Any> ServiceLocator.lookup(desc: ServiceDescriptor): T = lookup(T::class.java, desc)

private val ZipEntry.fileName: String
get() = name.substringAfterLast("/", name)

Expand Down
6 changes: 4 additions & 2 deletions core/src/main/kotlin/utilities/Uri.kt
@@ -1,8 +1,10 @@
package org.jetbrains.dokka.utilities

import org.jetbrains.dokka.*
import java.net.URI


@InternalDokkaApi
@Deprecated("Deprecated for removal") // Unused in Dokka
fun URI.relativeTo(uri: URI): URI {
// Normalize paths to remove . and .. segments
val base = uri.normalize()
Expand Down Expand Up @@ -37,4 +39,4 @@ fun URI.relativeTo(uri: URI): URI {
append(it)
}
})
}
}
3 changes: 3 additions & 0 deletions core/src/main/kotlin/utilities/associateWithNotNull.kt
@@ -1,5 +1,8 @@
package org.jetbrains.dokka.utilities

import org.jetbrains.dokka.*

@InternalDokkaApi
inline fun <K, V : Any> Iterable<K>.associateWithNotNull(valueSelector: (K) -> V?): Map<K, V> {
@Suppress("UNCHECKED_CAST")
return associateWith { valueSelector(it) }.filterValues { it != null } as Map<K, V>
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/kotlin/utilities/cast.kt
@@ -1,5 +1,8 @@
package org.jetbrains.dokka.utilities

import org.jetbrains.dokka.*

@InternalDokkaApi
inline fun <reified T> Any.cast(): T {
return this as T
}
@@ -1,15 +1,19 @@
package org.jetbrains.dokka.utilities

import kotlinx.coroutines.*
import org.jetbrains.dokka.*

@InternalDokkaApi
suspend inline fun <A, B> Iterable<A>.parallelMap(crossinline f: suspend (A) -> B): List<B> = coroutineScope {
map { async { f(it) } }.awaitAll()
}

@InternalDokkaApi
suspend inline fun <A, B> Iterable<A>.parallelMapNotNull(crossinline f: suspend (A) -> B?): List<B> = coroutineScope {
map { async { f(it) } }.awaitAll().filterNotNull()
}

@InternalDokkaApi
suspend inline fun <A> Iterable<A>.parallelForEach(crossinline f: suspend (A) -> Unit): Unit = coroutineScope {
forEach { launch { f(it) } }
}
2 changes: 1 addition & 1 deletion integration-tests/build.gradle.kts
Expand Up @@ -3,7 +3,7 @@ plugins {
}

dependencies {
api(projects.testUtils)
implementation(kotlin("test-junit"))
implementation(libs.kotlinx.coroutines.core)
implementation(libs.jsoup)
implementation(libs.eclipse.jgit)
Expand Down
@@ -1,17 +1,32 @@
package org.jetbrains.dokka.it.gradle

import org.gradle.testkit.runner.TaskOutcome
import org.jetbrains.dokka.test.assumeAndroidSdkInstalled
import org.junit.*
import org.junit.runners.Parameterized.Parameters
import java.io.File
import kotlin.test.*
import kotlin.test.Test

class Android0GradleIntegrationTest(override val versions: BuildVersions) : AbstractGradleIntegrationTest() {

companion object {
@get:JvmStatic
@get:Parameters(name = "{0}")
val versions = TestedVersions.ANDROID

/**
* Indicating whether or not the current machine executing the test is a CI
*/
private val isCI: Boolean get() = System.getenv("CI") == "true"

private val isAndroidSdkInstalled: Boolean = System.getenv("ANDROID_SDK_ROOT") != null ||
System.getenv("ANDROID_HOME") != null

fun assumeAndroidSdkInstalled() {
if (isCI) return
Assume.assumeTrue(isAndroidSdkInstalled)
}

}

@BeforeTest
Expand Down
Expand Up @@ -34,7 +34,7 @@ fun AbstractIntegrationTest.applyGitDiffFromFile(diffFile: File) {
private fun removeGitFile(repository: Path) =
repository.toFile()
.listFiles().orEmpty()
.filter { it.name.toLowerCase() == ".git" }
.filter { it.name.lowercase() == ".git" }
.forEach { it.delete() }


1 change: 0 additions & 1 deletion plugins/all-modules-page/build.gradle.kts
Expand Up @@ -32,7 +32,6 @@ dependencies {
implementation(libs.kotlinx.html)
implementation(libs.jsoup)

testImplementation(projects.testUtils)
testImplementation(projects.core.testApi)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
Expand Down
1 change: 0 additions & 1 deletion plugins/android-documentation/build.gradle.kts
Expand Up @@ -13,7 +13,6 @@ dependencies {

testImplementation(projects.plugins.base)
testImplementation(projects.plugins.base.baseTestUtils)
testImplementation(projects.testUtils)
testImplementation(projects.core.testApi)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
Expand Down
1 change: 0 additions & 1 deletion plugins/base/base-test-utils/build.gradle.kts
Expand Up @@ -17,7 +17,6 @@ dependencies {
implementation(libs.jsoup)
implementation(kotlin("test-junit"))

testImplementation(projects.testUtils)
testImplementation(projects.core.testApi)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
Expand Down
1 change: 0 additions & 1 deletion plugins/base/build.gradle.kts
Expand Up @@ -30,7 +30,6 @@ dependencies {
implementation(libs.kotlinx.html)

testImplementation(projects.kotlinAnalysis)
testImplementation(projects.testUtils)
testImplementation(projects.core.testApi)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
Expand Down
1 change: 0 additions & 1 deletion plugins/gfm/build.gradle.kts
Expand Up @@ -12,7 +12,6 @@ dependencies {
testImplementation(projects.plugins.base)
testImplementation(projects.plugins.base.baseTestUtils)
implementation(libs.jackson.kotlin)
testImplementation(projects.testUtils)
testImplementation(projects.core.testApi)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
Expand Down
1 change: 0 additions & 1 deletion plugins/gfm/gfm-template-processing/build.gradle.kts
Expand Up @@ -16,7 +16,6 @@ dependencies {

implementation(libs.kotlinx.coroutines.core)

testImplementation(projects.testUtils)
testImplementation(projects.core.testApi)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
Expand Down
1 change: 0 additions & 1 deletion plugins/javadoc/build.gradle.kts
Expand Up @@ -18,7 +18,6 @@ dependencies {
implementation(libs.kotlinx.coroutines.core)

testImplementation(projects.plugins.base.baseTestUtils)
testImplementation(projects.testUtils)
testImplementation(projects.core.testApi)

testImplementation(libs.jsoup)
Expand Down
@@ -1,8 +1,8 @@
package org.jetbrains.dokka.test
package org.jetbrains.dokka.javadoc

import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract
import kotlin.contracts.*

// TODO replace with assertIs<T> from kotlin-test as part of #2924
@OptIn(ExperimentalContracts::class)
inline fun <reified T> assertIsInstance(obj: Any?): T {
contract {
Expand Down
Expand Up @@ -4,7 +4,6 @@ import org.jetbrains.dokka.javadoc.pages.AllClassesPage
import org.jetbrains.dokka.javadoc.pages.LinkJavadocListEntry
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.pages.ContentKind
import org.jetbrains.dokka.test.assertIsInstance
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test

Expand Down
Expand Up @@ -3,7 +3,6 @@ package org.jetbrains.dokka.javadoc
import org.jetbrains.dokka.javadoc.pages.JavadocClasslikePageNode
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.jetbrains.dokka.test.assertIsInstance

internal class JavadocClasslikeTemplateMapTest : AbstractJavadocTemplateMapTest() {

Expand Down
Expand Up @@ -3,7 +3,6 @@ package org.jetbrains.dokka.javadoc
import org.jetbrains.dokka.javadoc.pages.JavadocModulePageNode
import org.jetbrains.dokka.javadoc.pages.RowJavadocListEntry
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.test.assertIsInstance
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import java.io.File
Expand Down
Expand Up @@ -4,7 +4,6 @@ import org.jetbrains.dokka.javadoc.pages.JavadocContentKind
import org.jetbrains.dokka.javadoc.pages.JavadocPackagePageNode
import org.jetbrains.dokka.javadoc.pages.RowJavadocListEntry
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.test.assertIsInstance
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import java.io.File
Expand Down
1 change: 0 additions & 1 deletion plugins/jekyll/build.gradle.kts
Expand Up @@ -11,7 +11,6 @@ dependencies {
implementation(projects.plugins.base)
implementation(projects.plugins.gfm)

testImplementation(projects.testUtils)
testImplementation(projects.core.testApi)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
Expand Down
1 change: 0 additions & 1 deletion plugins/jekyll/jekyll-template-processing/build.gradle.kts
Expand Up @@ -18,7 +18,6 @@ dependencies {

implementation(libs.kotlinx.coroutines.core)

testImplementation(projects.testUtils)
testImplementation(projects.core.testApi)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
Expand Down
1 change: 0 additions & 1 deletion plugins/kotlin-as-java/build.gradle.kts
Expand Up @@ -16,7 +16,6 @@ dependencies {
testImplementation(libs.jsoup)
testImplementation(projects.kotlinAnalysis)

testImplementation(projects.testUtils)
testImplementation(projects.core.testApi)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
Expand Down
1 change: 0 additions & 1 deletion plugins/mathjax/build.gradle.kts
Expand Up @@ -16,7 +16,6 @@ dependencies {
testImplementation(kotlin("test-junit"))
testImplementation(projects.kotlinAnalysis)

testImplementation(projects.testUtils)
testImplementation(projects.core.testApi)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
Expand Down
1 change: 0 additions & 1 deletion plugins/templating/build.gradle.kts
Expand Up @@ -28,7 +28,6 @@ dependencies {
implementation(libs.jsoup)
testImplementation(projects.plugins.base.baseTestUtils)

testImplementation(projects.testUtils)
testImplementation(projects.core.testApi)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
Expand Down
1 change: 0 additions & 1 deletion plugins/versioning/build.gradle.kts
Expand Up @@ -28,7 +28,6 @@ dependencies {
implementation(libs.jsoup)
implementation(libs.apache.mavenArtifact)

testImplementation(projects.testUtils)
testImplementation(projects.core.testApi)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
Expand Down
1 change: 0 additions & 1 deletion runners/gradle-plugin/build.gradle.kts
Expand Up @@ -13,7 +13,6 @@ dependencies {
compileOnly(libs.gradlePlugin.kotlin)
compileOnly(libs.gradlePlugin.android)

testImplementation(projects.testUtils)
testImplementation(libs.gradlePlugin.kotlin)
testImplementation(libs.gradlePlugin.android)
}
Expand Down
2 changes: 0 additions & 2 deletions settings.gradle.kts
Expand Up @@ -88,8 +88,6 @@ include(
":integration-tests:cli",
":integration-tests:maven",

":test-utils",

":mkdocs",
)

Expand Down