From 02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33 Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Thu, 31 Aug 2023 20:16:01 +0200 Subject: Enable explicit API mode (#3139) --- core/src/main/kotlin/utilities/Collections.kt | 4 +-- core/src/main/kotlin/utilities/DokkaLogging.kt | 31 ++++++++++++---------- core/src/main/kotlin/utilities/Html.kt | 6 ++--- .../utilities/SelfRepresentingSingletonSet.kt | 2 +- core/src/main/kotlin/utilities/ServiceLocator.kt | 14 +++++----- core/src/main/kotlin/utilities/Uri.kt | 2 +- .../main/kotlin/utilities/associateWithNotNull.kt | 2 +- core/src/main/kotlin/utilities/cast.kt | 2 +- .../utilities/parallelCollectionOperations.kt | 6 ++--- 9 files changed, 36 insertions(+), 33 deletions(-) (limited to 'core/src/main/kotlin/utilities') diff --git a/core/src/main/kotlin/utilities/Collections.kt b/core/src/main/kotlin/utilities/Collections.kt index bcc77021..e0b84a28 100644 --- a/core/src/main/kotlin/utilities/Collections.kt +++ b/core/src/main/kotlin/utilities/Collections.kt @@ -12,7 +12,7 @@ import org.jetbrains.dokka.InternalDokkaApi * locally for convenience. */ @InternalDokkaApi -inline fun Iterable<*>.firstIsInstanceOrNull(): T? { +public inline fun Iterable<*>.firstIsInstanceOrNull(): T? { for (element in this) if (element is T) return element return null } @@ -23,7 +23,7 @@ inline fun Iterable<*>.firstIsInstanceOrNull(): T? { * locally for convenience. */ @InternalDokkaApi -inline fun Sequence<*>.firstIsInstanceOrNull(): T? { +public inline fun Sequence<*>.firstIsInstanceOrNull(): T? { for (element in this) if (element is T) return element return null } diff --git a/core/src/main/kotlin/utilities/DokkaLogging.kt b/core/src/main/kotlin/utilities/DokkaLogging.kt index 52492930..7855c9c1 100644 --- a/core/src/main/kotlin/utilities/DokkaLogging.kt +++ b/core/src/main/kotlin/utilities/DokkaLogging.kt @@ -6,17 +6,18 @@ package org.jetbrains.dokka.utilities import java.util.concurrent.atomic.AtomicInteger -interface DokkaLogger { - var warningsCount: Int - var errorsCount: Int - fun debug(message: String) - fun info(message: String) - fun progress(message: String) - fun warn(message: String) - fun error(message: String) +public interface DokkaLogger { + public var warningsCount: Int + public var errorsCount: Int + + public fun debug(message: String) + public fun info(message: String) + public fun progress(message: String) + public fun warn(message: String) + public fun error(message: String) } -fun DokkaLogger.report() { +public fun DokkaLogger.report() { if (warningsCount > 0 || errorsCount > 0) { info( "Generation completed with $warningsCount warning" + @@ -29,20 +30,22 @@ fun DokkaLogger.report() { } } -enum class LoggingLevel(val index: Int) { +public enum class LoggingLevel( + public val index: Int +) { DEBUG(0), PROGRESS(1), INFO(2), WARN(3), ERROR(4); } /** * Used to decouple the transport layer from logger and make it convenient for testing */ -fun interface MessageEmitter : (String) -> Unit { - companion object { - val consoleEmitter: MessageEmitter = MessageEmitter { message -> println(message) } +public fun interface MessageEmitter : (String) -> Unit { + public companion object { + public val consoleEmitter: MessageEmitter = MessageEmitter { message -> println(message) } } } -class DokkaConsoleLogger( +public class DokkaConsoleLogger( private val minLevel: LoggingLevel = LoggingLevel.PROGRESS, private val emitter: MessageEmitter = MessageEmitter.consoleEmitter ) : DokkaLogger { diff --git a/core/src/main/kotlin/utilities/Html.kt b/core/src/main/kotlin/utilities/Html.kt index 4f34eab0..fc2330d2 100644 --- a/core/src/main/kotlin/utilities/Html.kt +++ b/core/src/main/kotlin/utilities/Html.kt @@ -13,11 +13,11 @@ import java.net.URLEncoder * Replaces & with &, < with < and > with > */ @InternalDokkaApi -fun String.htmlEscape(): String = replace("&", "&").replace("<", "<").replace(">", ">").replace("\"", """) +public fun String.htmlEscape(): String = replace("&", "&").replace("<", "<").replace(">", ">").replace("\"", """) @InternalDokkaApi -fun String.urlEncoded(): String = URLEncoder.encode(this, "UTF-8") +public fun String.urlEncoded(): String = URLEncoder.encode(this, "UTF-8") @InternalDokkaApi -fun String.formatToEndWithHtml() = +public fun String.formatToEndWithHtml(): String = if (endsWith(".html") || contains(Regex("\\.html#"))) this else "$this.html" diff --git a/core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt b/core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt index eb219804..57d3b1e1 100644 --- a/core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt +++ b/core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt @@ -9,7 +9,7 @@ import org.jetbrains.dokka.InternalDokkaApi @InternalDokkaApi @Suppress("DEPRECATION_ERROR") @Deprecated(message = "SelfRepresentingSingletonSet is an incorrect set implementation that breaks set invariants", level = DeprecationLevel.ERROR) -interface SelfRepresentingSingletonSet> : Set { +public interface SelfRepresentingSingletonSet> : Set { override val size: Int get() = 1 override fun contains(element: T): Boolean = this == element diff --git a/core/src/main/kotlin/utilities/ServiceLocator.kt b/core/src/main/kotlin/utilities/ServiceLocator.kt index 8ec886be..c8b8a837 100644 --- a/core/src/main/kotlin/utilities/ServiceLocator.kt +++ b/core/src/main/kotlin/utilities/ServiceLocator.kt @@ -13,19 +13,19 @@ 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) +public data class ServiceDescriptor(val name: String, val category: String, val description: String?, val className: String) @InternalDokkaApi -class ServiceLookupException(message: String) : Exception(message) +public class ServiceLookupException(message: String) : Exception(message) @InternalDokkaApi -object ServiceLocator { - fun lookup(clazz: Class, category: String, implementationName: String): T { +public object ServiceLocator { + public fun lookup(clazz: Class, category: String, implementationName: String): T { val descriptor = lookupDescriptor(category, implementationName) return lookup(clazz, descriptor) } - fun lookup( + public fun lookup( clazz: Class, descriptor: ServiceDescriptor ): T { @@ -56,7 +56,7 @@ object ServiceLocator { return ServiceDescriptor(implementationName, category, properties["description"]?.toString(), className) } - fun URL.toFile(): File { + public fun URL.toFile(): File { assert(protocol == "file") return try { @@ -66,7 +66,7 @@ object ServiceLocator { } } - fun allServices(category: String): List { + public fun allServices(category: String): List { val entries = this.javaClass.classLoader.getResources("dokka/$category")?.toList() ?: emptyList() return entries.flatMap { diff --git a/core/src/main/kotlin/utilities/Uri.kt b/core/src/main/kotlin/utilities/Uri.kt index ceee14bd..7e6b3fbe 100644 --- a/core/src/main/kotlin/utilities/Uri.kt +++ b/core/src/main/kotlin/utilities/Uri.kt @@ -9,7 +9,7 @@ import java.net.URI @InternalDokkaApi @Deprecated("Deprecated for removal") // Unused in Dokka -fun URI.relativeTo(uri: URI): URI { +public fun URI.relativeTo(uri: URI): URI { // Normalize paths to remove . and .. segments val base = uri.normalize() val child = this.normalize() diff --git a/core/src/main/kotlin/utilities/associateWithNotNull.kt b/core/src/main/kotlin/utilities/associateWithNotNull.kt index 38531108..29e37d13 100644 --- a/core/src/main/kotlin/utilities/associateWithNotNull.kt +++ b/core/src/main/kotlin/utilities/associateWithNotNull.kt @@ -7,7 +7,7 @@ package org.jetbrains.dokka.utilities import org.jetbrains.dokka.InternalDokkaApi @InternalDokkaApi -inline fun Iterable.associateWithNotNull(valueSelector: (K) -> V?): Map { +public inline fun Iterable.associateWithNotNull(valueSelector: (K) -> V?): Map { @Suppress("UNCHECKED_CAST") return associateWith { valueSelector(it) }.filterValues { it != null } as Map } diff --git a/core/src/main/kotlin/utilities/cast.kt b/core/src/main/kotlin/utilities/cast.kt index cbd77456..c2598a33 100644 --- a/core/src/main/kotlin/utilities/cast.kt +++ b/core/src/main/kotlin/utilities/cast.kt @@ -7,6 +7,6 @@ package org.jetbrains.dokka.utilities import org.jetbrains.dokka.InternalDokkaApi @InternalDokkaApi -inline fun Any.cast(): T { +public inline fun Any.cast(): T { return this as T } diff --git a/core/src/main/kotlin/utilities/parallelCollectionOperations.kt b/core/src/main/kotlin/utilities/parallelCollectionOperations.kt index 1bb563c9..001fca0b 100644 --- a/core/src/main/kotlin/utilities/parallelCollectionOperations.kt +++ b/core/src/main/kotlin/utilities/parallelCollectionOperations.kt @@ -11,16 +11,16 @@ import kotlinx.coroutines.launch import org.jetbrains.dokka.InternalDokkaApi @InternalDokkaApi -suspend inline fun Iterable.parallelMap(crossinline f: suspend (A) -> B): List = coroutineScope { +public suspend inline fun Iterable.parallelMap(crossinline f: suspend (A) -> B): List = coroutineScope { map { async { f(it) } }.awaitAll() } @InternalDokkaApi -suspend inline fun Iterable.parallelMapNotNull(crossinline f: suspend (A) -> B?): List = coroutineScope { +public suspend inline fun Iterable.parallelMapNotNull(crossinline f: suspend (A) -> B?): List = coroutineScope { map { async { f(it) } }.awaitAll().filterNotNull() } @InternalDokkaApi -suspend inline fun Iterable.parallelForEach(crossinline f: suspend (A) -> Unit): Unit = coroutineScope { +public suspend inline fun Iterable.parallelForEach(crossinline f: suspend (A) -> Unit): Unit = coroutineScope { forEach { launch { f(it) } } } -- cgit