aboutsummaryrefslogtreecommitdiff
path: root/plugins/all-module-page/src/main/kotlin/templates/PathToRootSubstitutor.kt
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/all-module-page/src/main/kotlin/templates/PathToRootSubstitutor.kt')
-rw-r--r--plugins/all-module-page/src/main/kotlin/templates/PathToRootSubstitutor.kt16
1 files changed, 16 insertions, 0 deletions
diff --git a/plugins/all-module-page/src/main/kotlin/templates/PathToRootSubstitutor.kt b/plugins/all-module-page/src/main/kotlin/templates/PathToRootSubstitutor.kt
new file mode 100644
index 00000000..992ee7ed
--- /dev/null
+++ b/plugins/all-module-page/src/main/kotlin/templates/PathToRootSubstitutor.kt
@@ -0,0 +1,16 @@
+package org.jetbrains.dokka.allModulesPage.templates
+
+import org.jetbrains.dokka.base.DokkaBase
+import org.jetbrains.dokka.base.templating.PathToRootSubstitutionCommand
+import org.jetbrains.dokka.base.templating.SubstitutionCommand
+import org.jetbrains.dokka.plugability.DokkaContext
+import org.jetbrains.dokka.plugability.query
+import java.nio.file.Path
+
+class PathToRootSubstitutor(private val dokkaContext: DokkaContext) : Substitutor {
+ override fun trySubstitute(context: TemplatingContext<SubstitutionCommand>, match: MatchResult): String? =
+ if (context.command is PathToRootSubstitutionCommand) {
+ context.output.toPath().parent.relativize(dokkaContext.configuration.outputDir.toPath()).toString() + "/"
+ } else null
+
+} \ No newline at end of file