From fdf8a298f586d7e334c312346b70b59c64c8d037 Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Thu, 21 Jan 2021 00:34:43 +0100 Subject: Empty modules filtering (#1699) --- .../kotlin/templates/AddToNavigationCommandResolutionTest.kt | 2 +- .../kotlin/templates/AddToSearchCommandResolutionTest.kt | 2 +- .../kotlin/templates/SubstitutionCommandResolutionTest.kt | 2 +- .../test/kotlin/templates/TemplatingDokkaTestGenerator.kt | 6 ++++++ .../src/test/kotlin/templates/TestTemplatingGeneration.kt | 12 ++++++++++-- 5 files changed, 19 insertions(+), 5 deletions(-) (limited to 'plugins/templating/src/test/kotlin/templates') diff --git a/plugins/templating/src/test/kotlin/templates/AddToNavigationCommandResolutionTest.kt b/plugins/templating/src/test/kotlin/templates/AddToNavigationCommandResolutionTest.kt index 19c940c2..a1e11dfe 100644 --- a/plugins/templating/src/test/kotlin/templates/AddToNavigationCommandResolutionTest.kt +++ b/plugins/templating/src/test/kotlin/templates/AddToNavigationCommandResolutionTest.kt @@ -127,7 +127,7 @@ class AddToNavigationCommandResolutionTest : TemplatingAbstractTest() { module2Navigation.writeText(inputForModule("module2")) testFromData(configuration, preserveOutputLocation = true) { - submoduleProcessingStage = { ctx -> + finishProcessingSubmodules = { ctx -> test(ctx) } } diff --git a/plugins/templating/src/test/kotlin/templates/AddToSearchCommandResolutionTest.kt b/plugins/templating/src/test/kotlin/templates/AddToSearchCommandResolutionTest.kt index a962d524..049cef96 100644 --- a/plugins/templating/src/test/kotlin/templates/AddToSearchCommandResolutionTest.kt +++ b/plugins/templating/src/test/kotlin/templates/AddToSearchCommandResolutionTest.kt @@ -56,7 +56,7 @@ class AddToSearchCommandResolutionTest : TemplatingAbstractTest() { } testFromData(configuration, preserveOutputLocation = true) { - submoduleProcessingStage = { _ -> + finishProcessingSubmodules = { _ -> val expected = elements.map { it.copy(location = "module1/${it.location}") } + elements.map { it.copy(location = "module2/${it.location}") } diff --git a/plugins/templating/src/test/kotlin/templates/SubstitutionCommandResolutionTest.kt b/plugins/templating/src/test/kotlin/templates/SubstitutionCommandResolutionTest.kt index d7143f11..9d211876 100644 --- a/plugins/templating/src/test/kotlin/templates/SubstitutionCommandResolutionTest.kt +++ b/plugins/templating/src/test/kotlin/templates/SubstitutionCommandResolutionTest.kt @@ -52,7 +52,7 @@ class SubstitutionCommandResolutionTest : TemplatingAbstractTest() { } testFromData(configuration, preserveOutputLocation = true){ - submoduleProcessingStage = { + finishProcessingSubmodules = { assertHtmlEqualsIgnoringWhitespace(expected, testedFile.readText()) } } diff --git a/plugins/templating/src/test/kotlin/templates/TemplatingDokkaTestGenerator.kt b/plugins/templating/src/test/kotlin/templates/TemplatingDokkaTestGenerator.kt index 906fb1ea..04420662 100644 --- a/plugins/templating/src/test/kotlin/templates/TemplatingDokkaTestGenerator.kt +++ b/plugins/templating/src/test/kotlin/templates/TemplatingDokkaTestGenerator.kt @@ -36,6 +36,9 @@ class TemplatingDokkaTestGenerator( generation.processSubmodules() submoduleProcessingStage(context) + + generation.finishProcessing() + finishProcessingSubmodules(context) } } @@ -43,15 +46,18 @@ class TemplatingDokkaTestGenerator( open class TemplatingTestMethods( open val pluginsSetupStage: (DokkaContext) -> Unit, open val submoduleProcessingStage: (DokkaContext) -> Unit, + open val finishProcessingSubmodules: (DokkaContext) -> Unit, ) : TestMethods class TemplatingTestBuilder : TestBuilder() { var pluginsSetupStage: (DokkaContext) -> Unit = {} var submoduleProcessingStage: (DokkaContext) -> Unit = {} + var finishProcessingSubmodules: (DokkaContext) -> Unit = {} override fun build() = TemplatingTestMethods( pluginsSetupStage, submoduleProcessingStage, + finishProcessingSubmodules, ) } diff --git a/plugins/templating/src/test/kotlin/templates/TestTemplatingGeneration.kt b/plugins/templating/src/test/kotlin/templates/TestTemplatingGeneration.kt index 0a5bae4b..5dbe2bbe 100644 --- a/plugins/templating/src/test/kotlin/templates/TestTemplatingGeneration.kt +++ b/plugins/templating/src/test/kotlin/templates/TestTemplatingGeneration.kt @@ -4,19 +4,27 @@ import org.jetbrains.dokka.Timer import org.jetbrains.dokka.generation.Generation import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.plugin +import org.jetbrains.dokka.plugability.query import org.jetbrains.dokka.plugability.querySingle -class TestTemplatingGeneration(context: DokkaContext): Generation { +class TestTemplatingGeneration(private val context: DokkaContext) : Generation { val templatingPlugin by lazy { context.plugin() } override fun Timer.generate() { report("Processing submodules") processSubmodules() + + report("Finishing processing") + finishProcessing() } fun processSubmodules() = - templatingPlugin.querySingle { templateProcessor }.process() + templatingPlugin.querySingle { submoduleTemplateProcessor }.process(context.configuration.modules) + + fun finishProcessing() = + templatingPlugin.query { templateProcessingStrategy }.forEach { it.finish(context.configuration.outputDir) } + override val generationName = "test template generation" } \ No newline at end of file -- cgit