diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2023-08-31 20:16:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-31 20:16:01 +0200 |
commit | 02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33 (patch) | |
tree | 66f6d6f089a93b863bf1144666491eca6729ad05 /core/src/main/kotlin/utilities | |
parent | 6a181a7a2b03ec263788d137610e86937a57d434 (diff) | |
download | dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.gz dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.bz2 dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.zip |
Enable explicit API mode (#3139)
Diffstat (limited to 'core/src/main/kotlin/utilities')
-rw-r--r-- | core/src/main/kotlin/utilities/Collections.kt | 4 | ||||
-rw-r--r-- | core/src/main/kotlin/utilities/DokkaLogging.kt | 31 | ||||
-rw-r--r-- | core/src/main/kotlin/utilities/Html.kt | 6 | ||||
-rw-r--r-- | core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/utilities/ServiceLocator.kt | 14 | ||||
-rw-r--r-- | core/src/main/kotlin/utilities/Uri.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/utilities/associateWithNotNull.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/utilities/cast.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/utilities/parallelCollectionOperations.kt | 6 |
9 files changed, 36 insertions, 33 deletions
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 <reified T : Any> Iterable<*>.firstIsInstanceOrNull(): T? { +public inline fun <reified T : Any> Iterable<*>.firstIsInstanceOrNull(): T? { for (element in this) if (element is T) return element return null } @@ -23,7 +23,7 @@ inline fun <reified T : Any> Iterable<*>.firstIsInstanceOrNull(): T? { * locally for convenience. */ @InternalDokkaApi -inline fun <reified T : Any> Sequence<*>.firstIsInstanceOrNull(): T? { +public inline fun <reified T : Any> 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<T : SelfRepresentingSingletonSet<T>> : Set<T> { +public interface SelfRepresentingSingletonSet<T : SelfRepresentingSingletonSet<T>> : Set<T> { 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 <T : Any> lookup(clazz: Class<T>, category: String, implementationName: String): T { +public object ServiceLocator { + public fun <T : Any> lookup(clazz: Class<T>, category: String, implementationName: String): T { val descriptor = lookupDescriptor(category, implementationName) return lookup(clazz, descriptor) } - fun <T : Any> lookup( + public fun <T : Any> lookup( clazz: Class<T>, 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<ServiceDescriptor> { + public fun allServices(category: String): List<ServiceDescriptor> { 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 <K, V : Any> Iterable<K>.associateWithNotNull(valueSelector: (K) -> V?): Map<K, V> { +public 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> } 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 <reified T> Any.cast(): T { +public inline fun <reified T> 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 <A, B> Iterable<A>.parallelMap(crossinline f: suspend (A) -> B): List<B> = coroutineScope { +public 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 { +public 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 { +public suspend inline fun <A> Iterable<A>.parallelForEach(crossinline f: suspend (A) -> Unit): Unit = coroutineScope { forEach { launch { f(it) } } } |