aboutsummaryrefslogtreecommitdiff
path: root/plugins/versioning/src/main/kotlin/versioning/ReplaceVersionsCommand.kt
blob: ad1edd2b9504356dc1f7a08ca6173ff145f11b1f (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
package org.jetbrains.dokka.versioning


import org.jetbrains.dokka.base.templating.Command
import org.jetbrains.dokka.base.templating.ReplaceVersionsCommand
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.templates.CommandHandler
import org.jsoup.nodes.Element
import java.io.File

class ReplaceVersionCommandHandler(context: DokkaContext) : CommandHandler {

    val versionsNavigationCreator by lazy {
        context.plugin<VersioningPlugin>().querySingle { versionsNavigationCreator }
    }

    override fun canHandle(command: Command): Boolean = command is ReplaceVersionsCommand

    override fun handleCommandAsTag(command: Command, element: Element, input: File, output: File) {
        element.empty()
        element.append(versionsNavigationCreator(output))
    }
}