aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/CoreExtensions.kt
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/kotlin/CoreExtensions.kt')
-rw-r--r--core/src/main/kotlin/CoreExtensions.kt44
1 files changed, 32 insertions, 12 deletions
diff --git a/core/src/main/kotlin/CoreExtensions.kt b/core/src/main/kotlin/CoreExtensions.kt
index f5fb7604..0eea416a 100644
--- a/core/src/main/kotlin/CoreExtensions.kt
+++ b/core/src/main/kotlin/CoreExtensions.kt
@@ -1,6 +1,9 @@
package org.jetbrains.dokka
-import org.jetbrains.dokka.plugability.ExtensionPoint
+import org.jetbrains.dokka.generation.Generation
+import org.jetbrains.dokka.generation.SingleModuleGeneration
+import org.jetbrains.dokka.plugability.*
+import org.jetbrains.dokka.plugability.LazyEvaluated
import org.jetbrains.dokka.renderers.Renderer
import org.jetbrains.dokka.transformers.documentation.DocumentableMerger
import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator
@@ -13,19 +16,36 @@ 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>()
- val documentableTransformer by coreExtension<DocumentableTransformer>()
- val documentableToPageTranslator by coreExtension<DocumentableToPageTranslator>()
- val allModulePageCreator by coreExtension<PageCreator>()
- val pageTransformer by coreExtension<PageTransformer>()
- val allModulePageTransformer by coreExtension<PageTransformer>()
- val renderer by coreExtension<Renderer>()
+ private val extensionDelegates = mutableListOf<Lazy<Extension<*, *, *>>>()
- private fun <T : Any> coreExtension() = object {
+ val preGenerationCheck by coreExtensionPoint<PreGenerationChecker>()
+ val generation by coreExtensionPoint<Generation>()
+ val sourceToDocumentableTranslator by coreExtensionPoint<SourceToDocumentableTranslator>()
+ val preMergeDocumentableTransformer by coreExtensionPoint<PreMergeDocumentableTransformer>()
+ val documentableMerger by coreExtensionPoint<DocumentableMerger>()
+ val documentableTransformer by coreExtensionPoint<DocumentableTransformer>()
+ val documentableToPageTranslator by coreExtensionPoint<DocumentableToPageTranslator>()
+ val allModulePageCreator by coreExtensionPoint<PageCreator>()
+ val pageTransformer by coreExtensionPoint<PageTransformer>()
+ val allModulePageTransformer by coreExtensionPoint<PageTransformer>()
+ val renderer by coreExtensionPoint<Renderer>()
+
+ val singleGeneration by generation extendWith LazyEvaluated.fromRecipe(::SingleModuleGeneration)
+
+ private fun <T : Any> coreExtensionPoint() = object {
operator fun provideDelegate(thisRef: CoreExtensions, property: KProperty<*>): Lazy<ExtensionPoint<T>> =
lazy { ExtensionPoint<T>(thisRef::class.qualifiedName!!, property.name) }
}
+
+ private infix fun <T: Any> ExtensionPoint<T>.extendWith(action: LazyEvaluated<T>) = object {
+ operator fun provideDelegate(thisRef: CoreExtensions, property: KProperty<*>): Lazy<Extension<T, OrderingKind.None, OverrideKind.None>> =
+ lazy { Extension(this@extendWith, thisRef::class.qualifiedName!!, property.name, action) }
+ .also { extensionDelegates += it }
+ }
+
+ internal fun installTo(context: DokkaContextConfiguration) {
+ extensionDelegates.forEach {
+ context.installExtension(it.value)
+ }
+ }
} \ No newline at end of file