aboutsummaryrefslogtreecommitdiff
path: root/plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2023-08-31 20:16:01 +0200
committerGitHub <noreply@github.com>2023-08-31 20:16:01 +0200
commit02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33 (patch)
tree66f6d6f089a93b863bf1144666491eca6729ad05 /plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt
parent6a181a7a2b03ec263788d137610e86937a57d434 (diff)
downloaddokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.gz
dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.bz2
dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.zip
Enable explicit API mode (#3139)
Diffstat (limited to 'plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt')
-rw-r--r--plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt35
1 files changed, 19 insertions, 16 deletions
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<DokkaModuleDescription>): TemplatingResult
+public interface SubmoduleTemplateProcessor : TemplateProcessor {
+ public fun process(modules: List<DokkaModuleDescription>): 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<DokkaModuleDescription>) =
- runBlocking(Dispatchers.Default) {
+ override fun process(modules: List<DokkaModuleDescription>): 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<TemplateProcessingStrategy> =
context.plugin<TemplatingPlugin>().query { templateProcessingStrategy }
@@ -89,13 +90,15 @@ class DefaultMultiModuleTemplateProcessor(
}
}
-data class TemplatingContext<out T : Command>(
+public data class TemplatingContext<out T : Command>(
val input: File,
val output: File,
val body: List<Node>,
val command: T,
)
-data class TemplatingResult(val modules: List<String> = emptyList()) {
- operator fun plus(rhs: TemplatingResult): TemplatingResult = TemplatingResult((modules + rhs.modules).distinct())
+public data class TemplatingResult(val modules: List<String> = emptyList()) {
+ public operator fun plus(rhs: TemplatingResult): TemplatingResult {
+ return TemplatingResult((modules + rhs.modules).distinct())
+ }
}