aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/plugability/DokkaPlugin.kt
diff options
context:
space:
mode:
authorKrzysztof Romanwoski <kromanowski@virtuslab.com>2020-09-11 16:29:55 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-09-28 10:16:38 +0200
commitdb215639cef1a8ea4b0ac9761b9c23f7bac4e32d (patch)
tree136a0f825d6a7504bac232790db233c71b91b080 /core/src/main/kotlin/plugability/DokkaPlugin.kt
parentaa745c95adde72a66ad559223c2055a15842736b (diff)
downloaddokka-db215639cef1a8ea4b0ac9761b9c23f7bac4e32d.tar.gz
dokka-db215639cef1a8ea4b0ac9761b9c23f7bac4e32d.tar.bz2
dokka-db215639cef1a8ea4b0ac9761b9c23f7bac4e32d.zip
Create java-like api for plugins
Diffstat (limited to 'core/src/main/kotlin/plugability/DokkaPlugin.kt')
-rw-r--r--core/src/main/kotlin/plugability/DokkaPlugin.kt11
1 files changed, 8 insertions, 3 deletions
diff --git a/core/src/main/kotlin/plugability/DokkaPlugin.kt b/core/src/main/kotlin/plugability/DokkaPlugin.kt
index a62327d2..13f59f6e 100644
--- a/core/src/main/kotlin/plugability/DokkaPlugin.kt
+++ b/core/src/main/kotlin/plugability/DokkaPlugin.kt
@@ -10,6 +10,7 @@ import kotlin.reflect.full.createInstance
abstract class DokkaPlugin {
private val extensionDelegates = mutableListOf<KProperty<*>>()
+ private val unsafePlugins = mutableListOf<Lazy<Extension<*, *, *>>>()
@PublishedApi
internal var context: DokkaContext? = null
@@ -37,10 +38,14 @@ abstract class DokkaPlugin {
}
internal fun internalInstall(ctx: DokkaContextConfiguration, configuration: DokkaConfiguration) {
- extensionDelegates.asSequence()
+ val extensionsToInstall = extensionDelegates.asSequence()
.filterIsInstance<KProperty1<DokkaPlugin, Extension<*, *, *>>>() // should be always true
- .map { it.get(this) }
- .forEach { if (configuration.(it.condition)()) ctx.installExtension(it) }
+ .map { it.get(this) } + unsafePlugins.map{ it.value }
+ extensionsToInstall.forEach { if (configuration.(it.condition)()) ctx.installExtension(it) }
+ }
+
+ protected fun <T: Any> unsafeInstall(ext: Lazy<Extension<T, *, *>>){
+ unsafePlugins.add(ext)
}
}