All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pages.RendererSpecificPage.kt Maven / Gradle / Ivy

Go to download

Dokka is an API documentation engine for Kotlin and Java, performing the same function as Javadoc for Java

There is a newer version: 2.0.0
Show newest version
package org.jetbrains.dokka.pages

import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.DisplaySourceSet
import org.jetbrains.dokka.renderers.Renderer
import kotlin.reflect.KClass

fun interface DriResolver: (DRI, Set) -> String?
fun interface PageResolver: (PageNode, PageNode?) -> String?

interface RendererSpecificPage : PageNode {
    val strategy: RenderingStrategy
}

class RendererSpecificRootPage(
    override val name: String,
    override val children: List,
    override val strategy: RenderingStrategy
) : RootPageNode(), RendererSpecificPage {
    override fun modified(name: String, children: List): RendererSpecificRootPage =
        RendererSpecificRootPage(name, children, strategy)
}

class RendererSpecificResourcePage(
    override val name: String,
    override val children: List,
    override val strategy: RenderingStrategy
): RendererSpecificPage {
    override fun modified(name: String, children: List): RendererSpecificResourcePage =
        RendererSpecificResourcePage(name, children, strategy)
}

sealed class RenderingStrategy {
    class Callback(val instructions: Renderer.(PageNode) -> String): RenderingStrategy()
    data class Copy(val from: String) : RenderingStrategy()
    data class Write(val text: String) : RenderingStrategy()
    data class DriLocationResolvableWrite(val contentToResolve: (DriResolver) -> String) : RenderingStrategy()
    data class PageLocationResolvableWrite(val contentToResolve: (PageResolver) -> String) : RenderingStrategy()
    object DoNothing : RenderingStrategy()

    companion object {
        inline operator fun  invoke(crossinline instructions: T.(PageNode) -> String) =
            Callback { if (this is T) instructions(it) else throw WrongRendererTypeException(T::class) }
    }
}

data class WrongRendererTypeException(val expectedType: KClass<*>): Exception()




© 2015 - 2025 Weber Informatics LLC | Privacy Policy