aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/renderers/preprocessors.kt
blob: b07db2bd363bccd9ab821b553000f41d58a59933 (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
package org.jetbrains.dokka.base.renderers

import org.jetbrains.dokka.base.resolvers.shared.LinkFormat
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.transformers.pages.PageTransformer

object RootCreator : PageTransformer {
    override fun invoke(input: RootPageNode) =
        RendererSpecificRootPage("", listOf(input), RenderingStrategy.DoNothing)
}


class PackageListCreator(val context: DokkaContext, val format: LinkFormat) : PageTransformer {
    override fun invoke(input: RootPageNode) =
        input.modified(children = input.children.map {
            it.takeUnless { it is ModulePageNode }
                ?: it.modified(children = it.children + packageList(input)) // TODO packageList should take module as an input
        })


    private fun packageList(pageNode: RootPageNode) =
        RendererSpecificResourcePage(
            "${pageNode.name}/package-list",
            emptyList(),
            RenderingStrategy.Write(PackageListService(context).formatPackageList(pageNode, format.formatName, format.linkExtension))
        )
}