From 3cb4702a68139788de6e1f7b087ced345f2b71ba Mon Sep 17 00:00:00 2001 From: Błażej Kardyś Date: Fri, 20 Nov 2020 17:23:10 +0100 Subject: Changing how multimodule location provider works and improving gfm link substitution --- .../src/main/kotlin/templates/PathToRootSubstitutor.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 plugins/all-modules-page/src/main/kotlin/templates/PathToRootSubstitutor.kt (limited to 'plugins/all-modules-page/src/main/kotlin/templates/PathToRootSubstitutor.kt') diff --git a/plugins/all-modules-page/src/main/kotlin/templates/PathToRootSubstitutor.kt b/plugins/all-modules-page/src/main/kotlin/templates/PathToRootSubstitutor.kt new file mode 100644 index 00000000..5056b724 --- /dev/null +++ b/plugins/all-modules-page/src/main/kotlin/templates/PathToRootSubstitutor.kt @@ -0,0 +1,14 @@ +package org.jetbrains.dokka.allModulesPage.templates + +import org.jetbrains.dokka.base.templating.PathToRootSubstitutionCommand +import org.jetbrains.dokka.base.templating.SubstitutionCommand +import org.jetbrains.dokka.plugability.DokkaContext +import java.io.File + +class PathToRootSubstitutor(private val dokkaContext: DokkaContext) : Substitutor { + override fun trySubstitute(context: TemplatingContext, match: MatchResult): String? = + if (context.command is PathToRootSubstitutionCommand) { + context.output.toPath().parent.relativize(dokkaContext.configuration.outputDir.toPath()).toString().split(File.separator).joinToString(separator = "/", postfix = "/") { it } + } else null + +} \ No newline at end of file -- cgit