aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin
diff options
context:
space:
mode:
authorBłażej Kardyś <bkardys@virtuslab.com>2020-09-08 12:10:59 +0200
committerKamil Doległo <9080183+kamildoleglo@users.noreply.github.com>2020-10-08 17:24:29 +0200
commitbe3fea152ae5dcec5ba9a29d86a69010d6b2e428 (patch)
tree35d657281f66fceeff6ee66bbb1aa85ff830262b /core/src/main/kotlin
parent68553bf4c1de2b640a376f0ac4755a6c5bc7dd79 (diff)
downloaddokka-be3fea152ae5dcec5ba9a29d86a69010d6b2e428.tar.gz
dokka-be3fea152ae5dcec5ba9a29d86a69010d6b2e428.tar.bz2
dokka-be3fea152ae5dcec5ba9a29d86a69010d6b2e428.zip
Adding configuration mpp check for javadoc
Diffstat (limited to 'core/src/main/kotlin')
-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
3 files changed, 26 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