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) --- .../src/main/kotlin/templates/TemplateProcessor.kt | 35 ++++++++++++---------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt') diff --git a/plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt b/plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt index 2cbbc215..762e3c8b 100644 --- a/plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt +++ b/plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt @@ -19,22 +19,22 @@ import org.jetbrains.dokka.plugability.querySingle import org.jsoup.nodes.Node import java.io.File -interface TemplateProcessor +public interface TemplateProcessor -interface SubmoduleTemplateProcessor : TemplateProcessor { - fun process(modules: List): TemplatingResult +public interface SubmoduleTemplateProcessor : TemplateProcessor { + public fun process(modules: List): TemplatingResult } -interface MultiModuleTemplateProcessor : TemplateProcessor { - fun process(generatedPagesTree: RootPageNode) +public interface MultiModuleTemplateProcessor : TemplateProcessor { + public fun process(generatedPagesTree: RootPageNode) } -interface TemplateProcessingStrategy { - fun process(input: File, output: File, moduleContext: DokkaModuleDescription?): Boolean - fun finish(output: File) {} +public interface TemplateProcessingStrategy { + public fun process(input: File, output: File, moduleContext: DokkaModuleDescription?): Boolean + public fun finish(output: File) {} } -class DefaultSubmoduleTemplateProcessor( +public class DefaultSubmoduleTemplateProcessor( private val context: DokkaContext, ) : SubmoduleTemplateProcessor { @@ -44,14 +44,15 @@ class DefaultSubmoduleTemplateProcessor( private val configuredModulesPaths = context.configuration.modules.associate { it.sourceOutputDirectory.absolutePath to it.name } - override fun process(modules: List) = - runBlocking(Dispatchers.Default) { + override fun process(modules: List): TemplatingResult { + return runBlocking(Dispatchers.Default) { coroutineScope { modules.fold(TemplatingResult()) { acc, module -> acc + module.sourceOutputDirectory.visit(context.configuration.outputDir.resolve(module.relativePathToOutputDirectory), module) } } } + } private suspend fun File.visit(target: File, module: DokkaModuleDescription, acc: TemplatingResult = TemplatingResult()): TemplatingResult = coroutineScope { @@ -74,8 +75,8 @@ class DefaultSubmoduleTemplateProcessor( } } -class DefaultMultiModuleTemplateProcessor( - val context: DokkaContext, +public class DefaultMultiModuleTemplateProcessor( + public val context: DokkaContext, ) : MultiModuleTemplateProcessor { private val strategies: List = context.plugin().query { templateProcessingStrategy } @@ -89,13 +90,15 @@ class DefaultMultiModuleTemplateProcessor( } } -data class TemplatingContext( +public data class TemplatingContext( val input: File, val output: File, val body: List, val command: T, ) -data class TemplatingResult(val modules: List = emptyList()) { - operator fun plus(rhs: TemplatingResult): TemplatingResult = TemplatingResult((modules + rhs.modules).distinct()) +public data class TemplatingResult(val modules: List = emptyList()) { + public operator fun plus(rhs: TemplatingResult): TemplatingResult { + return TemplatingResult((modules + rhs.modules).distinct()) + } } -- cgit