aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/base-test-utils/src
diff options
context:
space:
mode:
authorBłażej Kardyś <bkardys@virtuslab.com>2020-10-28 21:54:00 +0100
committerBłażej Kardyś <bkardys@virtuslab.com>2020-11-27 03:15:02 +0100
commited56e7bcdceac7a13eae851e02f642c0762aaf40 (patch)
tree0f06aee6b251dfbecdc8ebf55a1af37e66b091ba /plugins/base/base-test-utils/src
parentd41965ca3cb180bc82bd5dd6fa747d2b83381b31 (diff)
downloaddokka-ed56e7bcdceac7a13eae851e02f642c0762aaf40.tar.gz
dokka-ed56e7bcdceac7a13eae851e02f642c0762aaf40.tar.bz2
dokka-ed56e7bcdceac7a13eae851e02f642c0762aaf40.zip
Moving SingleGeneration to base pluing
Diffstat (limited to 'plugins/base/base-test-utils/src')
-rw-r--r--plugins/base/base-test-utils/src/main/kotlin/testRunner/baseTestApi.kt111
1 files changed, 111 insertions, 0 deletions
diff --git a/plugins/base/base-test-utils/src/main/kotlin/testRunner/baseTestApi.kt b/plugins/base/base-test-utils/src/main/kotlin/testRunner/baseTestApi.kt
new file mode 100644
index 00000000..cfc5ed43
--- /dev/null
+++ b/plugins/base/base-test-utils/src/main/kotlin/testRunner/baseTestApi.kt
@@ -0,0 +1,111 @@
+package org.jetbrains.dokka.base.testApi.testRunner
+
+import org.jetbrains.dokka.CoreExtensions
+import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.DokkaGenerator
+import org.jetbrains.dokka.base.generation.SingleModuleGeneration
+import org.jetbrains.dokka.model.DModule
+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 BaseDokkaTestGenerator(
+ configuration: DokkaConfiguration,
+ logger: DokkaLogger,
+ testMethods: BaseTestMethods,
+ additionalPlugins: List<DokkaPlugin> = emptyList()
+) : DokkaTestGenerator<BaseTestMethods>(configuration, logger, testMethods, additionalPlugins) {
+
+ override fun generate() = with(testMethods) {
+ val dokkaGenerator = DokkaGenerator(configuration, logger)
+
+ val context =
+ dokkaGenerator.initializePlugins(configuration, logger, additionalPlugins)
+ pluginsSetupStage(context)
+
+ val singleModuleGeneration = context.single(CoreExtensions.generation) as SingleModuleGeneration
+
+ val modulesFromPlatforms = singleModuleGeneration.createDocumentationModels()
+ documentablesCreationStage(modulesFromPlatforms)
+
+ verificationStage { singleModuleGeneration.validityCheck(context) }
+
+ val filteredModules = singleModuleGeneration.transformDocumentationModelBeforeMerge(modulesFromPlatforms)
+ documentablesFirstTransformationStep(filteredModules)
+
+ val documentationModel = singleModuleGeneration.mergeDocumentationModels(filteredModules)
+ documentablesMergingStage(documentationModel)
+
+ val transformedDocumentation = singleModuleGeneration.transformDocumentationModelAfterMerge(documentationModel)
+ documentablesTransformationStage(transformedDocumentation)
+
+ val pages = singleModuleGeneration.createPages(transformedDocumentation)
+ pagesGenerationStage(pages)
+
+ val transformedPages = singleModuleGeneration.transformPages(pages)
+ pagesTransformationStage(transformedPages)
+
+ singleModuleGeneration.render(transformedPages)
+ renderingStage(transformedPages, context)
+
+ singleModuleGeneration.reportAfterRendering()
+ }
+}
+
+data class BaseTestMethods(
+ override val pluginsSetupStage: (DokkaContext) -> Unit,
+ override val verificationStage: (() -> Unit) -> Unit,
+ override val documentablesCreationStage: (List<DModule>) -> Unit,
+ val documentablesFirstTransformationStep: (List<DModule>) -> Unit,
+ override val documentablesMergingStage: (DModule) -> Unit,
+ override val documentablesTransformationStage: (DModule) -> Unit,
+ override val pagesGenerationStage: (RootPageNode) -> Unit,
+ override val pagesTransformationStage: (RootPageNode) -> Unit,
+ override val renderingStage: (RootPageNode, DokkaContext) -> Unit
+) : TestMethods(
+ pluginsSetupStage,
+ verificationStage,
+ documentablesCreationStage,
+ documentablesMergingStage,
+ documentablesTransformationStage,
+ pagesGenerationStage,
+ pagesTransformationStage,
+ renderingStage,
+)
+
+class BaseTestBuilder : TestBuilder<BaseTestMethods>() {
+ var pluginsSetupStage: (DokkaContext) -> Unit = {}
+ var verificationStage: (() -> Unit) -> Unit = {}
+ var documentablesCreationStage: (List<DModule>) -> Unit = {}
+ var documentablesFirstTransformationStep: (List<DModule>) -> Unit = {}
+ var documentablesMergingStage: (DModule) -> Unit = {}
+ var documentablesTransformationStage: (DModule) -> Unit = {}
+ var pagesGenerationStage: (RootPageNode) -> Unit = {}
+ var pagesTransformationStage: (RootPageNode) -> Unit = {}
+ var renderingStage: (RootPageNode, DokkaContext) -> Unit = { a, b -> }
+
+ override fun build() = BaseTestMethods(
+ pluginsSetupStage,
+ verificationStage,
+ documentablesCreationStage,
+ documentablesFirstTransformationStep,
+ documentablesMergingStage,
+ documentablesTransformationStage,
+ pagesGenerationStage,
+ pagesTransformationStage,
+ renderingStage
+ )
+}
+
+open class BaseAbstractTest(logger: TestLogger = TestLogger(DokkaConsoleLogger)) : AbstractTest<BaseTestMethods, BaseTestBuilder, BaseDokkaTestGenerator>(
+ ::BaseTestBuilder,
+ ::BaseDokkaTestGenerator,
+ logger,
+) \ No newline at end of file