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/DokkaGenerator.kt | 40 ++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'core/src/main/kotlin/DokkaGenerator.kt') diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt index 6132b92f..9ae3adb4 100644 --- a/core/src/main/kotlin/DokkaGenerator.kt +++ b/core/src/main/kotlin/DokkaGenerator.kt @@ -18,33 +18,35 @@ import org.jetbrains.dokka.utilities.DokkaLogger * * [generate] method has been split into submethods for test reasons */ -class DokkaGenerator( +public class DokkaGenerator( private val configuration: DokkaConfiguration, private val logger: DokkaLogger ) { - fun generate() = timed(logger) { - report("Initializing plugins") - val context = initializePlugins(configuration, logger) + public fun generate() { + timed(logger) { + report("Initializing plugins") + val context = initializePlugins(configuration, logger) - runCatching { - context.single(CoreExtensions.generation).run { - logger.progress("Dokka is performing: $generationName") - generate() + runCatching { + context.single(CoreExtensions.generation).run { + logger.progress("Dokka is performing: $generationName") + generate() + } + }.exceptionOrNull()?.let { e -> + finalizeCoroutines() + throw e } - }.exceptionOrNull()?.let { e -> - finalizeCoroutines() - throw e - } - finalizeCoroutines() - }.dump("\n\n === TIME MEASUREMENT ===\n") + finalizeCoroutines() + }.dump("\n\n === TIME MEASUREMENT ===\n") + } - fun initializePlugins( + public fun initializePlugins( configuration: DokkaConfiguration, logger: DokkaLogger, additionalPlugins: List = emptyList() - ) = DokkaContext.create(configuration, logger, additionalPlugins) + ): DokkaContext = DokkaContext.create(configuration, logger, additionalPlugins) @OptIn(DelicateCoroutinesApi::class) private fun finalizeCoroutines() { @@ -54,15 +56,15 @@ class DokkaGenerator( } } -class Timer internal constructor(startTime: Long, private val logger: DokkaLogger?) { +public class Timer internal constructor(startTime: Long, private val logger: DokkaLogger?) { private val steps = mutableListOf("" to startTime) - fun report(name: String) { + public fun report(name: String) { logger?.progress(name) steps += (name to System.currentTimeMillis()) } - fun dump(prefix: String = "") { + public fun dump(prefix: String = "") { logger?.info(prefix) val namePad = steps.map { it.first.length }.maxOrNull() ?: 0 val timePad = steps.windowed(2).map { (p1, p2) -> p2.second - p1.second }.maxOrNull()?.toString()?.length ?: 0 -- cgit