diff options
author | Paweł Marks <pmarks@virtuslab.com> | 2020-02-17 11:27:37 +0100 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-02-18 13:28:23 +0100 |
commit | ba769f0695aaa9719b62ca32028fd3d24442f5ec (patch) | |
tree | 5f7ed51c2eaae6988648d5132ff8d5aa258c5bc5 /core/src/main/kotlin/plugability | |
parent | 2bfb7733dfef8da0271a01a7275ea42ecb69d93a (diff) | |
download | dokka-ba769f0695aaa9719b62ca32028fd3d24442f5ec.tar.gz dokka-ba769f0695aaa9719b62ca32028fd3d24442f5ec.tar.bz2 dokka-ba769f0695aaa9719b62ca32028fd3d24442f5ec.zip |
Moves comments to content conversion to base plugin
Diffstat (limited to 'core/src/main/kotlin/plugability')
-rw-r--r-- | core/src/main/kotlin/plugability/DefaultExtensions.kt | 5 | ||||
-rw-r--r-- | core/src/main/kotlin/plugability/DokkaPlugin.kt | 12 |
2 files changed, 9 insertions, 8 deletions
diff --git a/core/src/main/kotlin/plugability/DefaultExtensions.kt b/core/src/main/kotlin/plugability/DefaultExtensions.kt index 1a367d30..242eb6b8 100644 --- a/core/src/main/kotlin/plugability/DefaultExtensions.kt +++ b/core/src/main/kotlin/plugability/DefaultExtensions.kt @@ -1,23 +1,20 @@ package org.jetbrains.dokka.plugability import org.jetbrains.dokka.CoreExtensions -import org.jetbrains.dokka.pages.DocTagToContentConverter import org.jetbrains.dokka.renderers.FileWriter import org.jetbrains.dokka.renderers.OutputWriter import org.jetbrains.dokka.resolvers.DefaultLocationProviderFactory internal object DefaultExtensions { - private val converter: LazyEvaluated<DocTagToContentConverter> = LazyEvaluated.fromRecipe { DocTagToContentConverter(it) } private val providerFactory: LazyEvaluated<DefaultLocationProviderFactory> = LazyEvaluated.fromRecipe { DefaultLocationProviderFactory(it) } private val outputWriter: LazyEvaluated<OutputWriter> = LazyEvaluated.fromRecipe { FileWriter(it) } @Suppress("IMPLICIT_CAST_TO_ANY", "UNCHECKED_CAST") internal fun <T : Any, E : ExtensionPoint<T>> get(point: E, fullContext: DokkaContext): List<T> = when (point) { - CoreExtensions.commentsToContentConverter -> converter.get(fullContext) CoreExtensions.locationProviderFactory -> providerFactory.get(fullContext) - CoreExtensions.outputWriter -> outputWriter.get(fullContext) + CoreExtensions.outputWriter -> outputWriter.get(fullContext) else -> null }.let { listOfNotNull( it ) as List<T> } }
\ No newline at end of file diff --git a/core/src/main/kotlin/plugability/DokkaPlugin.kt b/core/src/main/kotlin/plugability/DokkaPlugin.kt index c00b0af3..d8fb7892 100644 --- a/core/src/main/kotlin/plugability/DokkaPlugin.kt +++ b/core/src/main/kotlin/plugability/DokkaPlugin.kt @@ -13,8 +13,7 @@ abstract class DokkaPlugin { @PublishedApi internal var context: DokkaContext? = null - protected inline fun <reified T : DokkaPlugin> plugin(): T = context?.plugin(T::class) - ?: throw IllegalStateException("Querying about plugins is only possible with dokka context initialised") + protected inline fun <reified T : DokkaPlugin> plugin(): T = context?.plugin(T::class) ?: throwIllegalQuery() protected fun <T : Any> extensionPoint() = object : ReadOnlyProperty<DokkaPlugin, ExtensionPoint<T>> { @@ -51,5 +50,10 @@ abstract class DokkaPlugin { } 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 + context?.let { it[extension()] } ?: throwIllegalQuery() + +inline fun <reified P : DokkaPlugin, reified E : Any> P.querySingle(extension: P.() -> ExtensionPoint<E>): E = + context?.single(extension()) ?: throwIllegalQuery() + +fun throwIllegalQuery(): Nothing = + throw IllegalStateException("Querying about plugins is only possible with dokka context initialised") |