aboutsummaryrefslogtreecommitdiff
path: root/plugins/all-module-page/src/main/kotlin/templates/TemplateProcessor.kt
diff options
context:
space:
mode:
authorPaweł Marks <pmarks@virtuslab.com>2020-09-22 17:29:21 +0200
committerBłażej Kardyś <bkardys@virtuslab.com>2020-11-27 03:15:02 +0100
commit80b6d1824960205e1c1d57c0c51e913d3c2360db (patch)
treeea40c9c6dc0bd24999312cfa49a01c43cb746926 /plugins/all-module-page/src/main/kotlin/templates/TemplateProcessor.kt
parentc8a83153a88fe6f5b50b6f459295421f90a21583 (diff)
downloaddokka-80b6d1824960205e1c1d57c0c51e913d3c2360db.tar.gz
dokka-80b6d1824960205e1c1d57c0c51e913d3c2360db.tar.bz2
dokka-80b6d1824960205e1c1d57c0c51e913d3c2360db.zip
Add templating commands to the html format
Diffstat (limited to 'plugins/all-module-page/src/main/kotlin/templates/TemplateProcessor.kt')
-rw-r--r--plugins/all-module-page/src/main/kotlin/templates/TemplateProcessor.kt41
1 files changed, 41 insertions, 0 deletions
diff --git a/plugins/all-module-page/src/main/kotlin/templates/TemplateProcessor.kt b/plugins/all-module-page/src/main/kotlin/templates/TemplateProcessor.kt
new file mode 100644
index 00000000..4c247d94
--- /dev/null
+++ b/plugins/all-module-page/src/main/kotlin/templates/TemplateProcessor.kt
@@ -0,0 +1,41 @@
+package org.jetbrains.dokka.allModulesPage.templates
+
+import kotlinx.coroutines.*
+import org.jetbrains.dokka.plugability.DokkaContext
+import java.io.File
+import java.nio.file.Files
+import java.nio.file.Path
+
+interface TemplateProcessor {
+ fun process()
+}
+
+interface TemplateProcessingStrategy {
+ suspend fun process(input: File, output: File)
+}
+
+class DefaultTemplateProcessor(
+ private val context: DokkaContext,
+ private val strategy: TemplateProcessingStrategy
+): TemplateProcessor {
+ override fun process() = runBlocking(Dispatchers.Default) {
+ context.configuration.modules.forEach {
+ launch {
+ it.sourceOutputDirectory.visit(context.configuration.outputDir.resolve(it.relativePathToOutputDirectory))
+ }
+ }
+ }
+
+ private suspend fun File.visit(target: File): Unit = coroutineScope {
+ val source = this@visit
+ if (source.isDirectory) {
+ target.mkdir()
+ source.list()?.forEach {
+ launch { source.resolve(it).visit(target.resolve(it)) }
+ }
+ } else {
+ strategy.process(source, target)
+ }
+ }
+}
+