aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/plugability
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2023-11-10 11:46:54 +0100
committerGitHub <noreply@github.com>2023-11-10 11:46:54 +0100
commit8e5c63d035ef44a269b8c43430f43f5c8eebfb63 (patch)
tree1b915207b2b9f61951ddbf0ff2e687efd053d555 /core/src/main/kotlin/plugability
parenta44efd4ba0c2e4ab921ff75e0f53fc9335aa79db (diff)
downloaddokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.gz
dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.bz2
dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.zip
Restructure the project to utilize included builds (#3174)
* Refactor and simplify artifact publishing * Update Gradle to 8.4 * Refactor and simplify convention plugins and build scripts Fixes #3132 --------- Co-authored-by: Adam <897017+aSemy@users.noreply.github.com> Co-authored-by: Oleg Yukhnevich <whyoleg@gmail.com>
Diffstat (limited to 'core/src/main/kotlin/plugability')
-rw-r--r--core/src/main/kotlin/plugability/DokkaContext.kt235
-rw-r--r--core/src/main/kotlin/plugability/DokkaJavaPlugin.kt78
-rw-r--r--core/src/main/kotlin/plugability/DokkaPlugin.kt114
-rw-r--r--core/src/main/kotlin/plugability/LazyEvaluated.kt21
-rw-r--r--core/src/main/kotlin/plugability/extensions.kt110
5 files changed, 0 insertions, 558 deletions
diff --git a/core/src/main/kotlin/plugability/DokkaContext.kt b/core/src/main/kotlin/plugability/DokkaContext.kt
deleted file mode 100644
index 1287e58b..00000000
--- a/core/src/main/kotlin/plugability/DokkaContext.kt
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.dokka.plugability
-
-import org.jetbrains.dokka.DokkaConfiguration
-import org.jetbrains.dokka.utilities.DokkaLogger
-import java.io.File
-import java.net.URLClassLoader
-import java.util.*
-import kotlin.reflect.KClass
-import kotlin.reflect.full.createInstance
-
-public interface DokkaContext {
- public fun <T : DokkaPlugin> plugin(kclass: KClass<T>): T?
-
- public operator fun <T, E> get(point: E): List<T>
- where T : Any, E : ExtensionPoint<T>
-
- public fun <T, E> single(point: E): T where T : Any, E : ExtensionPoint<T>
-
- public val logger: DokkaLogger
- public val configuration: DokkaConfiguration
- public val unusedPoints: Collection<ExtensionPoint<*>>
-
- public companion object {
- public fun create(
- configuration: DokkaConfiguration,
- logger: DokkaLogger,
- pluginOverrides: List<DokkaPlugin>
- ): DokkaContext =
- DokkaContextConfigurationImpl(logger, configuration).apply {
- // File(it.path) is a workaround for an incorrect filesystem in a File instance returned by Gradle.
- configuration.pluginsClasspath.map { File(it.path).toURI().toURL() }
- .toTypedArray()
- .let { URLClassLoader(it, this.javaClass.classLoader) }
- .also { checkClasspath(it) }
- .let { ServiceLoader.load(DokkaPlugin::class.java, it) }
- .let { it + pluginOverrides }
- .forEach { install(it) }
- topologicallySortAndPrune()
- }.also { it.logInitialisationInfo() }
- }
-}
-
-public inline fun <reified T : DokkaPlugin> DokkaContext.plugin(): T = plugin(T::class)
- ?: throw java.lang.IllegalStateException("Plugin ${T::class.qualifiedName} is not present in context.")
-
-public fun interface DokkaContextConfiguration {
- public fun installExtension(extension: Extension<*, *, *>)
-}
-
-private class DokkaContextConfigurationImpl(
- override val logger: DokkaLogger,
- override val configuration: DokkaConfiguration
-) : DokkaContext, DokkaContextConfiguration {
- private val plugins = mutableMapOf<KClass<*>, DokkaPlugin>()
- private val pluginStubs = mutableMapOf<KClass<*>, DokkaPlugin>()
- val extensions = mutableMapOf<ExtensionPoint<*>, MutableList<Extension<*, *, *>>>()
- val pointsUsed: MutableSet<ExtensionPoint<*>> = mutableSetOf()
- val pointsPopulated: MutableSet<ExtensionPoint<*>> = mutableSetOf()
- override val unusedPoints: Set<ExtensionPoint<*>>
- get() = pointsPopulated - pointsUsed
-
- private enum class State {
- UNVISITED,
- VISITING,
- VISITED;
- }
-
- private sealed class Suppression {
- data class ByExtension(val extension: Extension<*, *, *>) : Suppression() {
- override fun toString() = extension.toString()
- }
-
- data class ByPlugin(val plugin: DokkaPlugin) : Suppression() {
- override fun toString() = "Plugin ${plugin::class.qualifiedName}"
- }
- }
-
- private val rawExtensions = mutableListOf<Extension<*, *, *>>()
- private val rawAdjacencyList = mutableMapOf<Extension<*, *, *>, MutableList<Extension<*, *, *>>>()
- private val suppressedExtensions = mutableMapOf<Extension<*, *, *>, MutableList<Suppression>>()
-
- fun topologicallySortAndPrune() {
- pointsPopulated.clear()
- extensions.clear()
-
- val overridesInfo = processOverrides()
- val extensionsToSort = overridesInfo.keys
- val adjacencyList = translateAdjacencyList(overridesInfo)
-
- val verticesWithState = extensionsToSort.associateWithTo(mutableMapOf()) { State.UNVISITED }
- val result: MutableList<Extension<*, *, *>> = mutableListOf()
-
- fun visit(n: Extension<*, *, *>) {
- val state = verticesWithState[n]
- if (state == State.VISITED)
- return
- if (state == State.VISITING)
- throw Error("Detected cycle in plugins graph")
- verticesWithState[n] = State.VISITING
- adjacencyList[n]?.forEach { visit(it) }
- verticesWithState[n] = State.VISITED
- result += n
- }
-
- extensionsToSort.forEach(::visit)
-
- val filteredResult = result.asReversed().filterNot { it in suppressedExtensions }
-
- filteredResult.mapTo(pointsPopulated) { it.extensionPoint }
- filteredResult.groupByTo(extensions) { it.extensionPoint }
- }
-
- private fun processOverrides(): Map<Extension<*, *, *>, Set<Extension<*, *, *>>> {
- val buckets = rawExtensions.associateWithTo(mutableMapOf()) { setOf(it) }
- suppressedExtensions.forEach { (extension, suppressions) ->
- val mergedBucket = suppressions.filterIsInstance<Suppression.ByExtension>()
- .map { it.extension }
- .plus(extension)
- .flatMap { buckets[it].orEmpty() }
- .toSet()
- mergedBucket.forEach { buckets[it] = mergedBucket }
- }
- return buckets.values.distinct().associateBy(::findNotOverridden)
- }
-
- private fun findNotOverridden(bucket: Set<Extension<*, *, *>>): Extension<*, *, *> {
- // Let's filter out all suppressedExtensions that are not only overrides.
- // suppressedExtensions can be polluted by suppressions that completely disables the extension, and would break dokka behaviour
- // if not filtered out
- val suppressedExtensionsByOverrides = suppressedExtensions.filterNot { it.value.any { it !is Suppression.ByExtension } }
- val filtered = bucket.filterNot { it in suppressedExtensionsByOverrides }
- return filtered.singleOrNull()
- ?: throw IllegalStateException("Conflicting overrides: $filtered")
- }
-
- private fun translateAdjacencyList(
- overridesInfo: Map<Extension<*, *, *>, Set<Extension<*, *, *>>>
- ): Map<Extension<*, *, *>, List<Extension<*, *, *>>> {
- val reverseOverrideInfo = overridesInfo.flatMap { (ext, set) -> set.map { it to ext } }.toMap()
- return rawAdjacencyList.mapNotNull { (ext, list) ->
- reverseOverrideInfo[ext]?.to(list.mapNotNull { reverseOverrideInfo[it] })
- }.toMap()
- }
-
- @Suppress("UNCHECKED_CAST")
- override operator fun <T, E> get(point: E) where T : Any, E : ExtensionPoint<T> =
- actions(point).also { pointsUsed += point }.orEmpty() as List<T>
-
- @Suppress("UNCHECKED_CAST")
- override fun <T, E> single(point: E): T where T : Any, E : ExtensionPoint<T> {
- fun throwBadArity(substitution: String): Nothing = throw IllegalStateException(
- "$point was expected to have exactly one extension registered, but $substitution found."
- )
- pointsUsed += point
-
- val extensions = extensions[point].orEmpty() as List<Extension<T, *, *>>
- return when (extensions.size) {
- 0 -> throwBadArity("none was")
- 1 -> extensions.single().action.get(this)
- else -> throwBadArity("many were")
- }
- }
-
- private fun <E : ExtensionPoint<*>> actions(point: E) = extensions[point]?.map { it.action.get(this) }
-
- @Suppress("UNCHECKED_CAST")
- override fun <T : DokkaPlugin> plugin(kclass: KClass<T>) = (plugins[kclass] ?: pluginStubFor(kclass)) as T
-
- private fun <T : DokkaPlugin> pluginStubFor(kclass: KClass<T>): DokkaPlugin =
- pluginStubs.getOrPut(kclass) { kclass.createInstance().also { it.context = this } }
-
- fun install(plugin: DokkaPlugin) {
- plugins[plugin::class] = plugin
- plugin.context = this
- plugin.internalInstall(this, this.configuration)
-
- if (plugin is WithUnsafeExtensionSuppression) {
- plugin.extensionsSuppressed.forEach {
- suppressedExtensions.listFor(it) += Suppression.ByPlugin(plugin)
- }
- }
- }
-
- override fun installExtension(extension: Extension<*, *, *>) {
- rawExtensions += extension
-
- if (extension.ordering is OrderingKind.ByDsl) {
- val orderDsl = OrderDsl()
- orderDsl.(extension.ordering.block)()
-
- rawAdjacencyList.listFor(extension) += orderDsl.following.toList()
- orderDsl.previous.forEach { rawAdjacencyList.listFor(it) += extension }
- }
-
- if (extension.override is OverrideKind.Present) {
- fun root(ext: Extension<*, *, *>): List<Extension<*, *, *>> = if (ext.override is OverrideKind.Present) ext.override.overriden.flatMap(::root) else listOf(ext)
- if (extension.override.overriden.size > 1 && root(extension).distinct().size > 1)
- throw IllegalStateException("Extension $extension overrides extensions without common root")
- extension.override.overriden.forEach { overriden ->
- suppressedExtensions.listFor(overriden) += Suppression.ByExtension(extension)
- }
- }
- }
-
- fun logInitialisationInfo() {
- val pluginNames = plugins.values.map { it::class.qualifiedName.toString() }
-
- val loadedListForDebug = extensions.run { keys + values.flatten() }.toList()
- .joinToString(prefix = "[\n", separator = ",\n", postfix = "\n]") { "\t$it" }
-
- val suppressedList = suppressedExtensions.asSequence()
- .joinToString(prefix = "[\n", separator = ",\n", postfix = "\n]") {
- "\t${it.key} by " + (it.value.singleOrNull() ?: it.value)
- }
-
- logger.info("Loaded plugins: $pluginNames")
- logger.info("Loaded: $loadedListForDebug")
- logger.info("Suppressed: $suppressedList")
- }
-}
-
-private fun checkClasspath(classLoader: URLClassLoader) {
- classLoader.findResource(DokkaContext::class.java.name.replace('.', '/') + ".class")?.also {
- throw AssertionError(
- "Dokka API found on plugins classpath. This will lead to subtle bugs. " +
- "Please fix your plugins dependencies or exclude dokka api artifact from plugin classpath"
- )
- }
-}
-
-private fun <K, V> MutableMap<K, MutableList<V>>.listFor(key: K) = getOrPut(key, ::mutableListOf)
diff --git a/core/src/main/kotlin/plugability/DokkaJavaPlugin.kt b/core/src/main/kotlin/plugability/DokkaJavaPlugin.kt
deleted file mode 100644
index 3c2f5e65..00000000
--- a/core/src/main/kotlin/plugability/DokkaJavaPlugin.kt
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.dokka.plugability
-
-import org.jetbrains.dokka.DokkaConfiguration
-
-public class ExtensionBuilderStart internal constructor(){
- public fun <T: Any> extensionPoint(ext: ExtensionPoint<T>): ProvidedExtension<T> = ProvidedExtension(ext)
-}
-
-public class ProvidedExtension<T: Any> internal constructor(
- public val ext: ExtensionPoint<T>
-) {
- public fun fromInstance(inst: T): ExtensionBuilder<T> = createBuilder(
- LazyEvaluated.fromInstance(
- inst
- )
- )
- public fun fromRecipe(recipe: (DokkaContext) -> T): ExtensionBuilder<T> = createBuilder(
- LazyEvaluated.fromRecipe(recipe)
- )
-
- private val defaultName = "${ext.pointName}/in/${javaClass.simpleName}"
-
- private fun createBuilder(action: LazyEvaluated<T>) =
- ExtensionBuilder(defaultName, ext, action,
- emptyList(), emptyList(),
- OverrideKind.None, emptyList())
-}
-
-public data class ExtensionBuilder<T: Any> internal constructor(
- private val name: String,
- private val ext: ExtensionPoint<T>,
- private val action: LazyEvaluated<T>,
- private val before: List<Extension<*, *, *>>,
- private val after: List<Extension<*, *, *>>,
- private val override: OverrideKind = OverrideKind.None,
- private val conditions: List<(DokkaConfiguration) -> Boolean>
-){
- public fun build(): Extension<T, *, *> = Extension(
- ext,
- javaClass.name,
- name,
- action,
- OrderingKind.ByDsl {
- before(*before.toTypedArray())
- after(*after.toTypedArray())
- },
- override,
- conditions
- )
-
- public fun overrideExtension(extension: Extension<T, *, *>): ExtensionBuilder<T> = copy(override = OverrideKind.Present(listOf(extension)))
-
- public fun newOrdering(before: Array<out Extension<*, *, *>>, after: Array<out Extension<*, *, *>>): ExtensionBuilder<T> =
- copy(before = this.before + before, after = this.after + after)
-
- public fun before(vararg exts: Extension<*, *, *>): ExtensionBuilder<T> = copy(before = this.before + exts)
-
- public fun after(vararg exts: Extension<*, *, *>): ExtensionBuilder<T> = copy(after = this.after + exts)
-
- public fun addCondition(c: (DokkaConfiguration) -> Boolean): ExtensionBuilder<T> = copy(conditions = conditions + c)
-
- public fun name(name: String): ExtensionBuilder<T> = copy(name = name)
-}
-
-public abstract class DokkaJavaPlugin: DokkaPlugin() {
-
- public fun <T: DokkaPlugin> plugin(clazz: Class<T>): T =
- context?.plugin(clazz.kotlin) ?: throwIllegalQuery()
-
-
- public fun <T: Any> extend(func: (ExtensionBuilderStart) -> ExtensionBuilder<T>): Lazy<Extension<T, *, *>> =
- lazy { func(ExtensionBuilderStart()).build() }.also { unsafeInstall(it) }
-
-}
diff --git a/core/src/main/kotlin/plugability/DokkaPlugin.kt b/core/src/main/kotlin/plugability/DokkaPlugin.kt
deleted file mode 100644
index 7e15c325..00000000
--- a/core/src/main/kotlin/plugability/DokkaPlugin.kt
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.dokka.plugability
-
-import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule
-import com.fasterxml.jackson.dataformat.xml.XmlMapper
-import com.fasterxml.jackson.module.kotlin.readValue
-import org.jetbrains.dokka.DokkaConfiguration
-import org.jetbrains.dokka.utilities.DokkaLogger
-import org.jetbrains.dokka.utilities.parseJson
-import kotlin.properties.ReadOnlyProperty
-import kotlin.reflect.KProperty
-import kotlin.reflect.KProperty1
-
-@RequiresOptIn(
- level = RequiresOptIn.Level.WARNING,
- message = "All of Dokka's plugin API is in preview and it can be changed " +
- "in a backwards-incompatible manner with a best-effort migration. " +
- "By opting in, you acknowledge the risks of relying on preview API."
-)
-@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.FIELD)
-@Retention(AnnotationRetention.BINARY)
-public annotation class DokkaPluginApiPreview
-
-/**
- * Acknowledgement for empty methods that inform users about [DokkaPluginApiPreview]
- * Also, it allows to not propagates the annotation in IDE by default when a user autogenerate methods.
- */
-@DokkaPluginApiPreview
-public object PluginApiPreviewAcknowledgement
-
-public abstract class DokkaPlugin {
- private val extensionDelegates = mutableListOf<KProperty<*>>()
- private val unsafePlugins = mutableListOf<Lazy<Extension<*, *, *>>>()
-
- @PublishedApi
- internal var context: DokkaContext? = null
-
- protected val logger: DokkaLogger get() = context?.logger ?: throw IllegalStateException("No logger found")
-
- /**
- * @see PluginApiPreviewAcknowledgement
- */
- @OptIn(DokkaPluginApiPreview::class)
- protected abstract fun pluginApiPreviewAcknowledgement(): PluginApiPreviewAcknowledgement
- protected inline fun <reified T : DokkaPlugin> plugin(): T = context?.plugin(T::class) ?: throwIllegalQuery()
-
- protected fun <T : Any> extensionPoint(): ReadOnlyProperty<DokkaPlugin, ExtensionPoint<T>> {
- return ReadOnlyProperty { thisRef, property ->
- ExtensionPoint(
- thisRef::class.qualifiedName ?: throw AssertionError("Plugin must be named class"),
- property.name
- )
- }
- }
- protected fun <T : Any> extending(definition: ExtendingDSL.() -> Extension<T, *, *>): ExtensionProvider<T> {
- return ExtensionProvider(definition)
- }
-
- protected class ExtensionProvider<T : Any> internal constructor(
- private val definition: ExtendingDSL.() -> Extension<T, *, *>
- ) {
- public operator fun provideDelegate(thisRef: DokkaPlugin, property: KProperty<*>): Lazy<Extension<T, *, *>> {
- return lazy {
- ExtendingDSL(
- thisRef::class.qualifiedName ?: throw AssertionError("Plugin must be named class"),
- property.name
- ).definition()
- }.also { thisRef.extensionDelegates += property }
- }
- }
-
- internal fun internalInstall(ctx: DokkaContextConfiguration, configuration: DokkaConfiguration) {
- val extensionsToInstall = extensionDelegates.asSequence()
- .filterIsInstance<KProperty1<DokkaPlugin, Extension<*, *, *>>>() // should be always true
- .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)
- }
-}
-
-public interface WithUnsafeExtensionSuppression {
- public val extensionsSuppressed: List<Extension<*, *, *>>
-}
-
-public interface ConfigurableBlock
-
-public inline fun <reified P : DokkaPlugin, reified E : Any> P.query(extension: P.() -> ExtensionPoint<E>): List<E> =
- context?.let { it[extension()] } ?: throwIllegalQuery()
-
-public inline fun <reified P : DokkaPlugin, reified E : Any> P.querySingle(extension: P.() -> ExtensionPoint<E>): E =
- context?.single(extension()) ?: throwIllegalQuery()
-
-public fun throwIllegalQuery(): Nothing =
- throw IllegalStateException("Querying about plugins is only possible with dokka context initialised")
-
-public inline fun <reified T : DokkaPlugin, reified R : ConfigurableBlock> configuration(context: DokkaContext): R? =
- context.configuration.pluginsConfiguration.firstOrNull { it.fqPluginName == T::class.qualifiedName }
- ?.let { configuration ->
- when (configuration.serializationFormat) {
- DokkaConfiguration.SerializationFormat.JSON -> parseJson(configuration.values)
- DokkaConfiguration.SerializationFormat.XML -> XmlMapper(JacksonXmlModule().apply {
- setDefaultUseWrapper(
- true
- )
- }).readValue<R>(configuration.values)
- }
- }
diff --git a/core/src/main/kotlin/plugability/LazyEvaluated.kt b/core/src/main/kotlin/plugability/LazyEvaluated.kt
deleted file mode 100644
index 46f15b17..00000000
--- a/core/src/main/kotlin/plugability/LazyEvaluated.kt
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.dokka.plugability
-
-internal class LazyEvaluated<T : Any> private constructor(private val recipe: ((DokkaContext) -> T)? = null, private var value: T? = null) {
-
- @Synchronized
- internal fun get(context: DokkaContext): T {
- if(value == null) {
- value = recipe?.invoke(context)
- }
- return value ?: throw AssertionError("Incorrect initialized LazyEvaluated instance")
- }
-
- companion object {
- fun <T : Any> fromInstance(value: T) = LazyEvaluated(value = value)
- fun <T : Any> fromRecipe(recipe: (DokkaContext) -> T) = LazyEvaluated(recipe = recipe)
- }
-}
diff --git a/core/src/main/kotlin/plugability/extensions.kt b/core/src/main/kotlin/plugability/extensions.kt
deleted file mode 100644
index 04212d1a..00000000
--- a/core/src/main/kotlin/plugability/extensions.kt
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.dokka.plugability
-
-import org.jetbrains.dokka.DokkaConfiguration
-
-public data class ExtensionPoint<T : Any> internal constructor(
- internal val pluginClass: String,
- internal val pointName: String
-) {
- override fun toString(): String = "ExtensionPoint: $pluginClass/$pointName"
-}
-
-public sealed class OrderingKind {
- public object None : OrderingKind()
-
- public class ByDsl(
- public val block: (OrderDsl.() -> Unit)
- ) : OrderingKind()
-}
-
-public sealed class OverrideKind {
- public object None : OverrideKind()
- public class Present(
- public val overriden: List<Extension<*, *, *>>
- ) : OverrideKind()
-}
-
-public class Extension<T : Any, Ordering : OrderingKind, Override : OverrideKind> internal constructor(
- internal val extensionPoint: ExtensionPoint<T>,
- internal val pluginClass: String,
- internal val extensionName: String,
- internal val action: LazyEvaluated<T>,
- internal val ordering: Ordering,
- internal val override: Override,
- internal val conditions: List<DokkaConfiguration.() -> Boolean>
-) {
- override fun toString(): String = "Extension: $pluginClass/$extensionName"
-
- override fun equals(other: Any?): Boolean =
- if (other is Extension<*, *, *>) this.pluginClass == other.pluginClass && this.extensionName == other.extensionName
- else false
-
- override fun hashCode(): Int = listOf(pluginClass, extensionName).hashCode()
-
- public val condition: DokkaConfiguration.() -> Boolean
- get() = { conditions.all { it(this) } }
-}
-
-internal fun <T : Any> Extension(
- extensionPoint: ExtensionPoint<T>,
- pluginClass: String,
- extensionName: String,
- action: LazyEvaluated<T>
-) = Extension(extensionPoint, pluginClass, extensionName, action, OrderingKind.None, OverrideKind.None, emptyList())
-
-@DslMarker
-public annotation class ExtensionsDsl
-
-@ExtensionsDsl
-public class ExtendingDSL(private val pluginClass: String, private val extensionName: String) {
-
- public infix fun <T : Any> ExtensionPoint<T>.with(action: T): Extension<T, OrderingKind.None, OverrideKind.None> {
- return Extension(this, this@ExtendingDSL.pluginClass, extensionName, LazyEvaluated.fromInstance(action))
- }
-
- public infix fun <T : Any> ExtensionPoint<T>.providing(action: (DokkaContext) -> T): Extension<T, OrderingKind.None, OverrideKind.None> {
- return Extension(this, this@ExtendingDSL.pluginClass, extensionName, LazyEvaluated.fromRecipe(action))
- }
-
- public infix fun <T : Any, Override : OverrideKind> Extension<T, OrderingKind.None, Override>.order(
- block: OrderDsl.() -> Unit
- ): Extension<T, OrderingKind.ByDsl, Override> {
- return Extension(extensionPoint, pluginClass, extensionName, action, OrderingKind.ByDsl(block), override, conditions)
- }
-
- public infix fun <T : Any, Override : OverrideKind, Ordering: OrderingKind> Extension<T, Ordering, Override>.applyIf(
- condition: DokkaConfiguration.() -> Boolean
- ): Extension<T, Ordering, Override> {
- return Extension(extensionPoint, pluginClass, extensionName, action, ordering, override, conditions + condition)
- }
-
- public infix fun <T : Any, Override : OverrideKind, Ordering: OrderingKind> Extension<T, Ordering, Override>.override(
- overriden: List<Extension<T, *, *>>
- ): Extension<T, Ordering, OverrideKind.Present> {
- return Extension(extensionPoint, pluginClass, extensionName, action, ordering, OverrideKind.Present(overriden), conditions)
- }
-
- public infix fun <T : Any, Override : OverrideKind, Ordering: OrderingKind> Extension<T, Ordering, Override>.override(
- overriden: Extension<T, *, *>
- ): Extension<T, Ordering, OverrideKind.Present> {
- return this.override(listOf(overriden))
- }
-}
-
-@ExtensionsDsl
-public class OrderDsl {
- internal val previous = mutableSetOf<Extension<*, *, *>>()
- internal val following = mutableSetOf<Extension<*, *, *>>()
-
- public fun after(vararg extensions: Extension<*, *, *>) {
- previous += extensions
- }
-
- public fun before(vararg extensions: Extension<*, *, *>) {
- following += extensions
- }
-}