aboutsummaryrefslogtreecommitdiff
path: root/plugins/templating/src/main/kotlin/templates/ProjectNameSubstitutor.kt
blob: 9b22f31b5898a02d3f83102fd1d32b9ddd3e3ffe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

package templates

import org.jetbrains.dokka.base.templating.ProjectNameSubstitutionCommand
import org.jetbrains.dokka.base.templating.SubstitutionCommand
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.templates.Substitutor
import org.jetbrains.dokka.templates.TemplatingContext

public class ProjectNameSubstitutor(
    private val dokkaContext: DokkaContext
) : Substitutor {

    override fun trySubstitute(context: TemplatingContext<SubstitutionCommand>, match: MatchResult): String? =
        dokkaContext.configuration.moduleName.takeIf { context.command is ProjectNameSubstitutionCommand }
}