blob: 701886b7d90217acd7b6ccffc8e7b42fc43d6f82 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/*
* Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
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
public fun interface DriResolver: (DRI, Set<DisplaySourceSet>) -> String?
public fun interface PageResolver: (PageNode, PageNode?) -> String?
public interface RendererSpecificPage : PageNode {
public val strategy: RenderingStrategy
}
public class RendererSpecificRootPage(
override val name: String,
override val children: List<PageNode>,
override val strategy: RenderingStrategy
) : RootPageNode(), RendererSpecificPage {
override fun modified(name: String, children: List<PageNode>): RendererSpecificRootPage =
RendererSpecificRootPage(name, children, strategy)
}
public class RendererSpecificResourcePage(
override val name: String,
override val children: List<PageNode>,
override val strategy: RenderingStrategy
): RendererSpecificPage {
override fun modified(name: String, children: List<PageNode>): RendererSpecificResourcePage =
RendererSpecificResourcePage(name, children, strategy)
}
public sealed class RenderingStrategy {
public class Callback(public val instructions: Renderer.(PageNode) -> String): RenderingStrategy()
public data class Copy(val from: String) : RenderingStrategy()
public data class Write(val text: String) : RenderingStrategy()
public data class DriLocationResolvableWrite(val contentToResolve: (DriResolver) -> String) : RenderingStrategy()
public data class PageLocationResolvableWrite(val contentToResolve: (PageResolver) -> String) : RenderingStrategy()
public object DoNothing : RenderingStrategy()
public companion object {
public inline operator fun <reified T: Renderer> invoke(crossinline instructions: T.(PageNode) -> String): RenderingStrategy {
return Callback { if (this is T) instructions(it) else throw WrongRendererTypeException(T::class) }
}
}
}
public data class WrongRendererTypeException(val expectedType: KClass<*>): Exception()
|