package org.jetbrains.dokka.plugability data class ExtensionPoint internal constructor( internal val pluginClass: String, internal val pointName: String ) { override fun toString() = "ExtensionPoint: $pluginClass/$pointName" } class Extension internal constructor( internal val extensionPoint: ExtensionPoint, internal val pluginClass: String, internal val extensionName: String, internal val action: T, internal val ordering: (OrderDsl.() -> Unit)? = null ) { override fun toString() = "Extension: $pluginClass/$extensionName" override fun equals(other: Any?) = if (other is Extension<*>) this.pluginClass == other.extensionName && this.extensionName == other.extensionName else false override fun hashCode() = listOf(pluginClass, extensionName).hashCode() } internal data class Ordering(val previous: Set>, val following: Set>) @DslMarker annotation class ExtensionsDsl @ExtensionsDsl class ExtendingDSL(private val pluginClass: String, private val extensionName: String) { infix fun ExtensionPoint.with(action: T) = Extension(this, this@ExtendingDSL.pluginClass, extensionName, action) infix fun Extension.order(block: OrderDsl.() -> Unit) = Extension(extensionPoint, pluginClass, extensionName, action, block) } @ExtensionsDsl class OrderDsl { private val previous = mutableSetOf>() private val following = mutableSetOf>() fun after(vararg extensions: Extension<*>) { previous += extensions } fun before(vararg extensions: Extension<*>) { following += extensions } }