aboutsummaryrefslogtreecommitdiff
path: root/plugins/versioning/src/main/kotlin/versioning/ReplaceVersionsCommand.kt
blob: 728eac09d426c92d46e1ddc3347fb86cc4576739 (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 handleCommand(element: Element, command: Command, input: File, output: File) {
        element.empty()
        element.append(versionsNavigationCreator(output))
    }
}