aboutsummaryrefslogtreecommitdiff
path: root/plugins/all-modules-page/src/test/kotlin/MultiModuleDokkaTestGenerator.kt
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2020-12-17 12:14:40 +0100
committerGitHub <noreply@github.com>2020-12-17 12:14:40 +0100
commitfea7c42733a339ed19fc7471bb064f53de71cc6b (patch)
treeb3386822c1903026d079b8875bf3508ef20171e4 /plugins/all-modules-page/src/test/kotlin/MultiModuleDokkaTestGenerator.kt
parent2f7ee2b82cda39f6bd94c5200b83563418b68dd7 (diff)
downloaddokka-fea7c42733a339ed19fc7471bb064f53de71cc6b.tar.gz
dokka-fea7c42733a339ed19fc7471bb064f53de71cc6b.tar.bz2
dokka-fea7c42733a339ed19fc7471bb064f53de71cc6b.zip
Multimodule tests (#1670)
* Multimodule tests * Multimodule tests
Diffstat (limited to 'plugins/all-modules-page/src/test/kotlin/MultiModuleDokkaTestGenerator.kt')
-rw-r--r--plugins/all-modules-page/src/test/kotlin/MultiModuleDokkaTestGenerator.kt81
1 files changed, 81 insertions, 0 deletions
diff --git a/plugins/all-modules-page/src/test/kotlin/MultiModuleDokkaTestGenerator.kt b/plugins/all-modules-page/src/test/kotlin/MultiModuleDokkaTestGenerator.kt
new file mode 100644
index 00000000..c8542dfe
--- /dev/null
+++ b/plugins/all-modules-page/src/test/kotlin/MultiModuleDokkaTestGenerator.kt
@@ -0,0 +1,81 @@
+package org.jetbrains.dokka.allModulesPage
+
+import org.jetbrains.dokka.CoreExtensions
+import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.DokkaGenerator
+import org.jetbrains.dokka.pages.RootPageNode
+import org.jetbrains.dokka.plugability.DokkaContext
+import org.jetbrains.dokka.plugability.DokkaPlugin
+import org.jetbrains.dokka.testApi.logger.TestLogger
+import org.jetbrains.dokka.testApi.testRunner.AbstractTest
+import org.jetbrains.dokka.testApi.testRunner.DokkaTestGenerator
+import org.jetbrains.dokka.testApi.testRunner.TestBuilder
+import org.jetbrains.dokka.testApi.testRunner.TestMethods
+import org.jetbrains.dokka.utilities.DokkaConsoleLogger
+import org.jetbrains.dokka.utilities.DokkaLogger
+
+class MultiModuleDokkaTestGenerator(
+ configuration: DokkaConfiguration,
+ logger: DokkaLogger,
+ testMethods: MultiModuleTestMethods,
+ additionalPlugins: List<DokkaPlugin> = emptyList()
+) : DokkaTestGenerator<MultiModuleTestMethods>(
+ configuration,
+ logger,
+ testMethods,
+ additionalPlugins + AllModulesPagePlugin()
+) {
+ override fun generate() = with(testMethods) {
+ val dokkaGenerator = DokkaGenerator(configuration, logger)
+
+ val context =
+ dokkaGenerator.initializePlugins(configuration, logger, additionalPlugins + AllModulesPagePlugin())
+ pluginsSetupStage(context)
+
+ val generation = context.single(CoreExtensions.generation) as AllModulesPageGeneration
+
+ val allModulesPage = generation.createAllModulesPage()
+ allModulesPageCreationStage(allModulesPage)
+
+ val transformedPages = generation.transformAllModulesPage(allModulesPage)
+ pagesTransformationStage(transformedPages)
+
+ generation.render(transformedPages)
+ renderingStage(transformedPages, context)
+
+ generation.processSubmodules()
+ submoduleProcessingStage(context)
+ }
+
+}
+
+open class MultiModuleTestMethods(
+ open val pluginsSetupStage: (DokkaContext) -> Unit,
+ open val allModulesPageCreationStage: (RootPageNode) -> Unit,
+ open val pagesTransformationStage: (RootPageNode) -> Unit,
+ open val renderingStage: (RootPageNode, DokkaContext) -> Unit,
+ open val submoduleProcessingStage: (DokkaContext) -> Unit,
+) : TestMethods
+
+class MultiModuleTestBuilder : TestBuilder<MultiModuleTestMethods>() {
+ var pluginsSetupStage: (DokkaContext) -> Unit = {}
+ var allModulesPageCreationStage: (RootPageNode) -> Unit = {}
+ var pagesTransformationStage: (RootPageNode) -> Unit = {}
+ var renderingStage: (RootPageNode, DokkaContext) -> Unit = { _, _ -> }
+ var submoduleProcessingStage: (DokkaContext) -> Unit = {}
+
+ override fun build() = MultiModuleTestMethods(
+ pluginsSetupStage,
+ allModulesPageCreationStage,
+ pagesTransformationStage,
+ renderingStage,
+ submoduleProcessingStage,
+ )
+}
+
+abstract class MultiModuleAbstractTest(logger: TestLogger = TestLogger(DokkaConsoleLogger)) :
+ AbstractTest<MultiModuleTestMethods, MultiModuleTestBuilder, MultiModuleDokkaTestGenerator>(
+ ::MultiModuleTestBuilder,
+ ::MultiModuleDokkaTestGenerator,
+ logger,
+ )