diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-09-01 09:54:41 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-09-01 10:17:38 +0200 |
commit | c24e9b5b0f0ac9a80ff36282fe708e4ee0ecf707 (patch) | |
tree | 9e4f9e0e8d2eb8ed4c481ba3e4bd108eab341a60 /core | |
parent | 98c18f2a686c78283d5373b4d768bfbb10952f2d (diff) | |
download | dokka-c24e9b5b0f0ac9a80ff36282fe708e4ee0ecf707.tar.gz dokka-c24e9b5b0f0ac9a80ff36282fe708e4ee0ecf707.tar.bz2 dokka-c24e9b5b0f0ac9a80ff36282fe708e4ee0ecf707.zip |
Implement exitGenerationGracefully API
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/kotlin/DokkaGenerator.kt | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt index 2ba0c0a4..0921e5bc 100644 --- a/core/src/main/kotlin/DokkaGenerator.kt +++ b/core/src/main/kotlin/DokkaGenerator.kt @@ -73,6 +73,7 @@ class DokkaGenerator( context: DokkaContext ) = context.configuration.sourceSets .flatMap { sourceSet -> translateSources(sourceSet, context) } + .also { modules -> if (modules.isEmpty()) exitGenerationGracefully("Nothing to document") } fun transformDocumentationModelBeforeMerge( modulesFromPlatforms: List<DModule>, @@ -160,7 +161,15 @@ private fun timed(logger: DokkaLogger? = null, block: Timer.() -> Unit): Timer = Timer(System.currentTimeMillis(), logger).apply { try { block() + } catch (exit: GracefulGenerationExit) { + report("Exiting Generation: ${exit.reason}") } finally { report("") } } + +private fun exitGenerationGracefully(reason: String): Nothing { + throw GracefulGenerationExit(reason) +} + +private class GracefulGenerationExit(val reason: String) : Throwable() |