aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/CoreExtensions.kt2
-rw-r--r--core/src/main/kotlin/DokkaGenerator.kt12
-rw-r--r--core/src/main/kotlin/validity/PreGenerationChecker.kt12
-rw-r--r--core/test-api/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt4
-rw-r--r--core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt3
5 files changed, 33 insertions, 0 deletions
diff --git a/core/src/main/kotlin/CoreExtensions.kt b/core/src/main/kotlin/CoreExtensions.kt
index b8689154..f5fb7604 100644
--- a/core/src/main/kotlin/CoreExtensions.kt
+++ b/core/src/main/kotlin/CoreExtensions.kt
@@ -9,9 +9,11 @@ import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransf
import org.jetbrains.dokka.transformers.pages.PageCreator
import org.jetbrains.dokka.transformers.pages.PageTransformer
import org.jetbrains.dokka.transformers.sources.SourceToDocumentableTranslator
+import org.jetbrains.dokka.validity.PreGenerationChecker
import kotlin.reflect.KProperty
object CoreExtensions {
+ val preGenerationCheck by coreExtension<PreGenerationChecker>()
val sourceToDocumentableTranslator by coreExtension<SourceToDocumentableTranslator>()
val preMergeDocumentableTransformer by coreExtension<PreMergeDocumentableTransformer>()
val documentableMerger by coreExtension<DocumentableMerger>()
diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt
index bee85325..b6216bdb 100644
--- a/core/src/main/kotlin/DokkaGenerator.kt
+++ b/core/src/main/kotlin/DokkaGenerator.kt
@@ -28,6 +28,9 @@ class DokkaGenerator(
report("Initializing plugins")
val context = initializePlugins(configuration, logger)
+ report("Validity check")
+ validityCheck(context)
+
report("Creating documentation models")
val modulesFromPlatforms = createDocumentationModels(context)
@@ -136,6 +139,15 @@ class DokkaGenerator(
}
}
+ fun validityCheck(context: DokkaContext) {
+ val (preGenerationCheckResult, checkMessages) = context[CoreExtensions.preGenerationCheck].fold(
+ Pair(true, emptyList<String>())
+ ) { acc, checker -> checker() + acc }
+ if (!preGenerationCheckResult) throw DokkaException(
+ "Pre-generation validity check failed: ${checkMessages.joinToString(",")}"
+ )
+ }
+
private suspend fun translateSources(sourceSet: DokkaSourceSet, context: DokkaContext) =
context[CoreExtensions.sourceToDocumentableTranslator].parallelMap {
it.invoke(sourceSet, context)
diff --git a/core/src/main/kotlin/validity/PreGenerationChecker.kt b/core/src/main/kotlin/validity/PreGenerationChecker.kt
new file mode 100644
index 00000000..7cdad59b
--- /dev/null
+++ b/core/src/main/kotlin/validity/PreGenerationChecker.kt
@@ -0,0 +1,12 @@
+package org.jetbrains.dokka.validity
+
+interface PreGenerationChecker : () -> PreGenerationCheckerOutput {
+
+ override fun invoke(): PreGenerationCheckerOutput
+}
+
+data class PreGenerationCheckerOutput(val result: Boolean, val messages: List<String>) {
+
+ operator fun plus(pair: Pair<Boolean, List<String>>) =
+ Pair(result && pair.first, messages + pair.second)
+} \ No newline at end of file
diff --git a/core/test-api/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt b/core/test-api/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt
index 414919dc..98f8965c 100644
--- a/core/test-api/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt
+++ b/core/test-api/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt
@@ -19,6 +19,10 @@ internal class DokkaTestGenerator(
dokkaGenerator.initializePlugins(configuration, logger, additionalPlugins)
pluginsSetupStage(context)
+ verificationStage {
+ dokkaGenerator.validityCheck(context)
+ }
+
val modulesFromPlatforms = dokkaGenerator.createDocumentationModels(context)
documentablesCreationStage(modulesFromPlatforms)
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 db253a9d..0b3068fc 100644
--- a/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt
+++ b/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt
@@ -140,6 +140,7 @@ abstract class AbstractCoreTest(
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 = {}
@@ -151,6 +152,7 @@ abstract class AbstractCoreTest(
@PublishedApi
internal fun build() = TestMethods(
pluginsSetupStage,
+ verificationStage,
documentablesCreationStage,
documentablesFirstTransformationStep,
documentablesMergingStage,
@@ -193,6 +195,7 @@ 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,