diff options
author | Paweł Marks <pmarks@virtuslab.com> | 2020-02-17 10:55:44 +0100 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-02-18 13:28:23 +0100 |
commit | 2bfb7733dfef8da0271a01a7275ea42ecb69d93a (patch) | |
tree | c3e6369da1a795d1b2dcf8342629742ca0dfbde3 /core/src/main/kotlin/plugability | |
parent | f625cef495d625d81ee22e950083f57cc4fab875 (diff) | |
download | dokka-2bfb7733dfef8da0271a01a7275ea42ecb69d93a.tar.gz dokka-2bfb7733dfef8da0271a01a7275ea42ecb69d93a.tar.bz2 dokka-2bfb7733dfef8da0271a01a7275ea42ecb69d93a.zip |
Cleans up page mergers and moves them to base plugin
Diffstat (limited to 'core/src/main/kotlin/plugability')
-rw-r--r-- | core/src/main/kotlin/plugability/DefaultExtensions.kt | 4 | ||||
-rw-r--r-- | core/src/main/kotlin/plugability/DokkaContext.kt | 3 | ||||
-rw-r--r-- | core/src/main/kotlin/plugability/DokkaPlugin.kt | 6 |
3 files changed, 8 insertions, 5 deletions
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 <T : Any, E : ExtensionPoint<T>> get(point: E, fullContext: DokkaContext): List<T> = 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<T> } }
\ 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 <reified T: DokkaPlugin> 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 <reified P : DokkaPlugin, reified E : Any> P.query(extension: P.() -> ExtensionPoint<E>): List<E> = + context?.let { it[extension()] } + ?: throw IllegalStateException("Querying about plugins is only possible with dokka context initialised")
\ No newline at end of file |