aboutsummaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/kotlin/DokkaException.kt3
-rw-r--r--core/src/main/kotlin/DokkaGenerator.kt26
-rw-r--r--core/src/main/kotlin/configuration.kt1
-rw-r--r--core/src/main/kotlin/defaultConfiguration.kt3
4 files changed, 28 insertions, 5 deletions
diff --git a/core/src/main/kotlin/DokkaException.kt b/core/src/main/kotlin/DokkaException.kt
new file mode 100644
index 00000000..0010249c
--- /dev/null
+++ b/core/src/main/kotlin/DokkaException.kt
@@ -0,0 +1,3 @@
+package org.jetbrains.dokka
+
+class DokkaException(message: String) : RuntimeException(message)
diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt
index c8a892d7..b2e572d4 100644
--- a/core/src/main/kotlin/DokkaGenerator.kt
+++ b/core/src/main/kotlin/DokkaGenerator.kt
@@ -54,9 +54,7 @@ class DokkaGenerator(
report("Rendering")
render(transformedPages, context)
- context.unusedPoints.takeIf { it.isNotEmpty() }
- ?.also { logger.warn("Unused extension points found: ${it.joinToString(", ")}") }
- logger.report()
+ reportAfterRendering(context)
}.dump("\n\n === TIME MEASUREMENT ===\n")
fun generateAllModulesPage() = timed {
@@ -138,6 +136,20 @@ class DokkaGenerator(
renderer.render(transformedPages)
}
+ fun reportAfterRendering(context: DokkaContext) {
+ context.unusedPoints.takeIf { it.isNotEmpty() }?.also {
+ logger.warn("Unused extension points found: ${it.joinToString(", ")}")
+ }
+
+ logger.report()
+
+ if (context.configuration.failOnWarning && (logger.warningsCount > 0 || logger.errorsCount > 0)) {
+ throw DokkaException(
+ "Failed with warningCount=${logger.warningsCount} and errorCount=${logger.errorsCount}"
+ )
+ }
+ }
+
private fun createEnvironmentAndFacade(
configuration: DokkaConfiguration,
pass: DokkaConfiguration.PassConfiguration
@@ -211,4 +223,10 @@ private class Timer(startTime: Long, private val logger: DokkaLogger?) {
}
private fun timed(logger: DokkaLogger? = null, block: Timer.() -> Unit): Timer =
- Timer(System.currentTimeMillis(), logger).apply(block).apply { report("") } \ No newline at end of file
+ Timer(System.currentTimeMillis(), logger).apply {
+ try {
+ block()
+ } finally {
+ report("")
+ }
+ }
diff --git a/core/src/main/kotlin/configuration.kt b/core/src/main/kotlin/configuration.kt
index fab7af37..f5115435 100644
--- a/core/src/main/kotlin/configuration.kt
+++ b/core/src/main/kotlin/configuration.kt
@@ -33,6 +33,7 @@ interface DokkaConfiguration {
val modules: List<DokkaModuleDescription>
val pluginsClasspath: List<File>
val pluginsConfiguration: Map<String, String>
+ val failOnWarning: Boolean
interface PassConfiguration {
val moduleName: String
diff --git a/core/src/main/kotlin/defaultConfiguration.kt b/core/src/main/kotlin/defaultConfiguration.kt
index 23cf7e2d..4e83d3c3 100644
--- a/core/src/main/kotlin/defaultConfiguration.kt
+++ b/core/src/main/kotlin/defaultConfiguration.kt
@@ -11,7 +11,8 @@ data class DokkaConfigurationImpl(
override val passesConfigurations: List<PassConfigurationImpl>,
override val pluginsClasspath: List<File>,
override val pluginsConfiguration: Map<String, String>,
- override val modules: List<DokkaModuleDescriptionImpl>
+ override val modules: List<DokkaModuleDescriptionImpl>,
+ override val failOnWarning: Boolean
) : DokkaConfiguration
data class PassConfigurationImpl(