aboutsummaryrefslogtreecommitdiff
path: root/plugins/all-modules-page/src/main/kotlin/templates/TemplateProcessor.kt
diff options
context:
space:
mode:
authorBłażej Kardyś <bkardys@virtuslab.com>2021-01-05 17:59:38 +0100
committerGitHub <noreply@github.com>2021-01-05 17:59:38 +0100
commit1618e552c136e25d86bf0708e0d760841c77c139 (patch)
treec608ce91b020bb0ecbfe75d0f456a0eae84b4c51 /plugins/all-modules-page/src/main/kotlin/templates/TemplateProcessor.kt
parentef98e4b6505c3fdd192b1d5057c718079d27b972 (diff)
downloaddokka-1618e552c136e25d86bf0708e0d760841c77c139.tar.gz
dokka-1618e552c136e25d86bf0708e0d760841c77c139.tar.bz2
dokka-1618e552c136e25d86bf0708e0d760841c77c139.zip
Versioning (#1654)
* Adding versioning mechanism for multimodule * Versioning improvement * Refactor configuration, add ordering * Fix integration tests * Change packages, unignore test Co-authored-by: Marcin Aman <marcin.aman@gmail.com>
Diffstat (limited to 'plugins/all-modules-page/src/main/kotlin/templates/TemplateProcessor.kt')
-rw-r--r--plugins/all-modules-page/src/main/kotlin/templates/TemplateProcessor.kt60
1 files changed, 0 insertions, 60 deletions
diff --git a/plugins/all-modules-page/src/main/kotlin/templates/TemplateProcessor.kt b/plugins/all-modules-page/src/main/kotlin/templates/TemplateProcessor.kt
deleted file mode 100644
index 18d63df0..00000000
--- a/plugins/all-modules-page/src/main/kotlin/templates/TemplateProcessor.kt
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.jetbrains.dokka.allModulesPage.templates
-
-import kotlinx.coroutines.*
-import org.jetbrains.dokka.allModulesPage.AllModulesPagePlugin
-import org.jetbrains.dokka.base.templating.Command
-import org.jetbrains.dokka.plugability.DokkaContext
-import org.jetbrains.dokka.plugability.plugin
-import org.jetbrains.dokka.plugability.query
-import org.jsoup.nodes.Element
-import java.io.File
-import java.nio.file.Files
-import java.nio.file.Path
-import kotlin.coroutines.coroutineContext
-
-interface TemplateProcessor {
- fun process()
-}
-
-interface TemplateProcessingStrategy {
- suspend fun process(input: File, output: File): Boolean
- suspend fun finish(output: File) {}
-}
-
-class DefaultTemplateProcessor(
- private val context: DokkaContext,
-): TemplateProcessor {
-
- private val strategies: List<TemplateProcessingStrategy> = context.plugin<AllModulesPagePlugin>().query { templateProcessingStrategy }
-
- override fun process() = runBlocking(Dispatchers.Default) {
- coroutineScope {
- context.configuration.modules.forEach {
- launch {
- it.sourceOutputDirectory.visit(context.configuration.outputDir.resolve(it.relativePathToOutputDirectory))
- }
- }
- }
- strategies.map { it.finish(context.configuration.outputDir) }
- Unit
- }
-
- 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 {
- strategies.asSequence().first { it.process(source, target) }
- }
- }
-}
-
-data class TemplatingContext<out T: Command>(
- val input: File,
- val output: File,
- val element: Element,
- val command: T,
-) \ No newline at end of file