aboutsummaryrefslogtreecommitdiff
path: root/plugins/templating/src/main/kotlin
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2021-08-04 17:02:31 +0200
committerMarcin Aman <marcin.aman@gmail.com>2021-08-12 13:21:40 +0200
commit0fe8352ab057dfbbf690a723b2ccfc15b9977f4a (patch)
tree7017e7169950f907206832c862dce5e711e3cae8 /plugins/templating/src/main/kotlin
parent42c0320e0c5f2d79a5438558bb87d4668aa4c3cc (diff)
downloaddokka-0fe8352ab057dfbbf690a723b2ccfc15b9977f4a.tar.gz
dokka-0fe8352ab057dfbbf690a723b2ccfc15b9977f4a.tar.bz2
dokka-0fe8352ab057dfbbf690a723b2ccfc15b9977f4a.zip
Webhelp-like frontend
Diffstat (limited to 'plugins/templating/src/main/kotlin')
-rw-r--r--plugins/templating/src/main/kotlin/templates/ProjectNameSubstitutor.kt13
-rw-r--r--plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt5
2 files changed, 18 insertions, 0 deletions
diff --git a/plugins/templating/src/main/kotlin/templates/ProjectNameSubstitutor.kt b/plugins/templating/src/main/kotlin/templates/ProjectNameSubstitutor.kt
new file mode 100644
index 00000000..8fc12b6c
--- /dev/null
+++ b/plugins/templating/src/main/kotlin/templates/ProjectNameSubstitutor.kt
@@ -0,0 +1,13 @@
+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
+
+class ProjectNameSubstitutor(private val dokkaContext: DokkaContext) : Substitutor {
+
+ override fun trySubstitute(context: TemplatingContext<SubstitutionCommand>, match: MatchResult): String? =
+ dokkaContext.configuration.moduleName.takeIf { context.command is ProjectNameSubstitutionCommand }
+} \ No newline at end of file
diff --git a/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt b/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt
index 0842bb2b..418edcbf 100644
--- a/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt
+++ b/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt
@@ -4,6 +4,7 @@ import org.jetbrains.dokka.allModulesPage.templates.NavigationSearchTemplateStra
import org.jetbrains.dokka.allModulesPage.templates.PackageListProcessingStrategy
import org.jetbrains.dokka.allModulesPage.templates.PagesSearchTemplateStrategy
import org.jetbrains.dokka.plugability.DokkaPlugin
+import templates.ProjectNameSubstitutor
import templates.SourcesetDependencyProcessingStrategy
class TemplatingPlugin : DokkaPlugin() {
@@ -60,6 +61,10 @@ class TemplatingPlugin : DokkaPlugin() {
substitutor providing ::PathToRootSubstitutor
}
+ val projectNameSubstitutor by extending {
+ substitutor providing ::ProjectNameSubstitutor
+ }
+
val addToNavigationCommandHandler by extending {
directiveBasedCommandHandlers providing ::AddToNavigationCommandHandler
}