From 2bfb7733dfef8da0271a01a7275ea42ecb69d93a Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Mon, 17 Feb 2020 10:55:44 +0100 Subject: Cleans up page mergers and moves them to base plugin --- core/src/main/kotlin/plugability/DefaultExtensions.kt | 4 ---- core/src/main/kotlin/plugability/DokkaContext.kt | 3 +++ core/src/main/kotlin/plugability/DokkaPlugin.kt | 6 +++++- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'core/src/main/kotlin/plugability') diff --git a/core/src/main/kotlin/plugability/DefaultExtensions.kt b/core/src/main/kotlin/plugability/DefaultExtensions.kt index 828d1bf1..1a367d30 100644 --- a/core/src/main/kotlin/plugability/DefaultExtensions.kt +++ b/core/src/main/kotlin/plugability/DefaultExtensions.kt @@ -5,8 +5,6 @@ import org.jetbrains.dokka.pages.DocTagToContentConverter import org.jetbrains.dokka.renderers.FileWriter import org.jetbrains.dokka.renderers.OutputWriter import org.jetbrains.dokka.resolvers.DefaultLocationProviderFactory -import org.jetbrains.dokka.transformers.pages.DefaultPageMergerStrategy -import org.jetbrains.dokka.transformers.pages.DefaultPageNodeMerger internal object DefaultExtensions { @@ -18,10 +16,8 @@ internal object DefaultExtensions { internal fun > get(point: E, fullContext: DokkaContext): List = when (point) { CoreExtensions.commentsToContentConverter -> converter.get(fullContext) - CoreExtensions.pageTransformer -> DefaultPageNodeMerger(fullContext) CoreExtensions.locationProviderFactory -> providerFactory.get(fullContext) CoreExtensions.outputWriter -> outputWriter.get(fullContext) - CoreExtensions.pageMergerStrategy -> DefaultPageMergerStrategy(fullContext.logger) else -> null }.let { listOfNotNull( it ) as List } } \ No newline at end of file diff --git a/core/src/main/kotlin/plugability/DokkaContext.kt b/core/src/main/kotlin/plugability/DokkaContext.kt index b4be5862..bcf6e1e0 100644 --- a/core/src/main/kotlin/plugability/DokkaContext.kt +++ b/core/src/main/kotlin/plugability/DokkaContext.kt @@ -43,6 +43,9 @@ interface DokkaContext { } } +inline fun DokkaContext.plugin(): T = plugin(T::class) + ?: throw java.lang.IllegalStateException("Plugin ${T::class.qualifiedName} is not present in context.") + interface DokkaContextConfiguration { fun addExtensionDependencies(extension: Extension<*>) } diff --git a/core/src/main/kotlin/plugability/DokkaPlugin.kt b/core/src/main/kotlin/plugability/DokkaPlugin.kt index cdc92ca5..c00b0af3 100644 --- a/core/src/main/kotlin/plugability/DokkaPlugin.kt +++ b/core/src/main/kotlin/plugability/DokkaPlugin.kt @@ -48,4 +48,8 @@ abstract class DokkaPlugin { .map { it.get(this) } .forEach { if (it.condition.invoke(configuration)) ctx.addExtensionDependencies(it) } } -} \ No newline at end of file +} + +inline fun P.query(extension: P.() -> ExtensionPoint): List = + context?.let { it[extension()] } + ?: throw IllegalStateException("Querying about plugins is only possible with dokka context initialised") \ No newline at end of file -- cgit