diff options
author | Błażej Kardyś <bkardys@virtuslab.com> | 2020-10-28 21:54:00 +0100 |
---|---|---|
committer | Błażej Kardyś <bkardys@virtuslab.com> | 2020-11-27 03:15:02 +0100 |
commit | ed56e7bcdceac7a13eae851e02f642c0762aaf40 (patch) | |
tree | 0f06aee6b251dfbecdc8ebf55a1af37e66b091ba /core/test-api/src/main | |
parent | d41965ca3cb180bc82bd5dd6fa747d2b83381b31 (diff) | |
download | dokka-ed56e7bcdceac7a13eae851e02f642c0762aaf40.tar.gz dokka-ed56e7bcdceac7a13eae851e02f642c0762aaf40.tar.bz2 dokka-ed56e7bcdceac7a13eae851e02f642c0762aaf40.zip |
Moving SingleGeneration to base pluing
Diffstat (limited to 'core/test-api/src/main')
-rw-r--r-- | core/test-api/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt | 51 | ||||
-rw-r--r-- | core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt | 76 |
2 files changed, 32 insertions, 95 deletions
diff --git a/core/test-api/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt b/core/test-api/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt deleted file mode 100644 index 0f5814f6..00000000 --- a/core/test-api/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt +++ /dev/null @@ -1,51 +0,0 @@ -package org.jetbrains.dokka.testApi.testRunner - -import org.jetbrains.dokka.CoreExtensions -import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.DokkaGenerator -import org.jetbrains.dokka.generation.SingleModuleGeneration -import org.jetbrains.dokka.plugability.DokkaPlugin -import org.jetbrains.dokka.utilities.DokkaLogger - -internal class DokkaTestGenerator( - private val configuration: DokkaConfiguration, - private val logger: DokkaLogger, - private val testMethods: TestMethods, - private val additionalPlugins: List<DokkaPlugin> = emptyList() -) { - - 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() - } -} diff --git a/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt b/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt index 0b3068fc..380eb1d8 100644 --- a/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt +++ b/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt @@ -3,7 +3,6 @@ package org.jetbrains.dokka.testApi.testRunner import com.intellij.openapi.application.PathManager import org.jetbrains.dokka.* import org.jetbrains.dokka.model.DModule -import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.DokkaPlugin @@ -21,8 +20,10 @@ import java.nio.file.Path import java.nio.file.Paths // TODO: take dokka configuration from file -abstract class AbstractCoreTest( - protected val logger: TestLogger = TestLogger(DokkaConsoleLogger) +open class AbstractTest< M: TestMethods, T : TestBuilder<M>, D: DokkaTestGenerator<M> >( + protected val testBuilder: () -> T, + protected val dokkaTestGenerator: (DokkaConfiguration, DokkaLogger, M, List<DokkaPlugin>) -> D, + protected val logger: TestLogger, ) { protected fun getTestDataDir(name: String) = File("src/test/resources/$name").takeIf { it.exists() }?.toPath() @@ -32,9 +33,9 @@ abstract class AbstractCoreTest( configuration: DokkaConfigurationImpl, cleanupOutput: Boolean = true, pluginOverrides: List<DokkaPlugin> = emptyList(), - block: TestBuilder.() -> Unit + block: T.() -> Unit ) { - val testMethods = TestBuilder().apply(block).build() + val testMethods = testBuilder().apply(block).build() val tempDir = getTempDir(cleanupOutput) if (!cleanupOutput) logger.info("Output generated under: ${tempDir.root.absolutePath}") @@ -42,7 +43,7 @@ abstract class AbstractCoreTest( configuration.copy( outputDir = tempDir.root ) - DokkaTestGenerator( + dokkaTestGenerator( newConfiguration, logger, testMethods, @@ -56,9 +57,9 @@ abstract class AbstractCoreTest( cleanupOutput: Boolean = true, pluginOverrides: List<DokkaPlugin> = emptyList(), loggerForTest: DokkaLogger = logger, - block: TestBuilder.() -> Unit + block: T.() -> Unit ) { - val testMethods = TestBuilder().apply(block).build() + val testMethods = testBuilder().apply(block).build() val testDirPath = getTempDir(cleanupOutput).root.toPath() val fileMap = query.toFileMap() fileMap.materializeFiles(testDirPath.toAbsolutePath()) @@ -82,7 +83,7 @@ abstract class AbstractCoreTest( ) } ) - DokkaTestGenerator( + dokkaTestGenerator( newConfiguration, loggerForTest, testMethods, @@ -138,31 +139,6 @@ abstract class AbstractCoreTest( }.apply { create() } } - protected class TestBuilder { - 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 -> } - - @PublishedApi - internal fun build() = TestMethods( - pluginsSetupStage, - verificationStage, - documentablesCreationStage, - documentablesFirstTransformationStep, - documentablesMergingStage, - documentablesTransformationStage, - pagesGenerationStage, - pagesTransformationStage, - renderingStage - ) - } - protected fun dokkaConfiguration(block: TestDokkaConfigurationBuilder.() -> Unit): DokkaConfigurationImpl = testApi.testRunner.dokkaConfiguration(block) @@ -193,14 +169,26 @@ abstract class AbstractCoreTest( } } -data class TestMethods( - val pluginsSetupStage: (DokkaContext) -> Unit, - val verificationStage: (() -> Unit) -> Unit, - val documentablesCreationStage: (List<DModule>) -> Unit, - val documentablesFirstTransformationStep: (List<DModule>) -> Unit, - val documentablesMergingStage: (DModule) -> Unit, - val documentablesTransformationStage: (DModule) -> Unit, - val pagesGenerationStage: (RootPageNode) -> Unit, - val pagesTransformationStage: (RootPageNode) -> Unit, - val renderingStage: (RootPageNode, DokkaContext) -> Unit +open class TestMethods( + open val pluginsSetupStage: (DokkaContext) -> Unit, + open val verificationStage: (() -> Unit) -> Unit, + open val documentablesCreationStage: (List<DModule>) -> Unit, + open val documentablesMergingStage: (DModule) -> Unit, + open val documentablesTransformationStage: (DModule) -> Unit, + open val pagesGenerationStage: (RootPageNode) -> Unit, + open val pagesTransformationStage: (RootPageNode) -> Unit, + open val renderingStage: (RootPageNode, DokkaContext) -> Unit ) + +abstract class TestBuilder<M: TestMethods> { + abstract fun build(): M +} + +abstract class DokkaTestGenerator<T: TestMethods>( + protected val configuration: DokkaConfiguration, + protected val logger: DokkaLogger, + protected val testMethods: T, + protected val additionalPlugins: List<DokkaPlugin> = emptyList() +) { + abstract fun generate() +}
\ No newline at end of file |