aboutsummaryrefslogtreecommitdiff
path: root/plugins/all-module-page/src/main/kotlin/templates/PathToRootSubstitutor.kt
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2020-09-24 14:16:13 +0200
committerBłażej Kardyś <bkardys@virtuslab.com>2020-11-27 03:15:02 +0100
commitdc179bf9a649d925e7e64dbcaf52a2187416a1d5 (patch)
treec86de1bd76fae760e21380b5e99767ec45c82f32 /plugins/all-module-page/src/main/kotlin/templates/PathToRootSubstitutor.kt
parent52f64c664573567259f8f678d32924f86b4f147c (diff)
downloaddokka-dc179bf9a649d925e7e64dbcaf52a2187416a1d5.tar.gz
dokka-dc179bf9a649d925e7e64dbcaf52a2187416a1d5.tar.bz2
dokka-dc179bf9a649d925e7e64dbcaf52a2187416a1d5.zip
Implement basic link resolution
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