aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main
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/base/src/main
parent52f64c664573567259f8f678d32924f86b4f147c (diff)
downloaddokka-dc179bf9a649d925e7e64dbcaf52a2187416a1d5.tar.gz
dokka-dc179bf9a649d925e7e64dbcaf52a2187416a1d5.tar.bz2
dokka-dc179bf9a649d925e7e64dbcaf52a2187416a1d5.zip
Implement basic link resolution
Diffstat (limited to 'plugins/base/src/main')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt5
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/Tags.kt2
-rw-r--r--plugins/base/src/main/kotlin/resolvers/shared/PackageList.kt4
-rw-r--r--plugins/base/src/main/kotlin/templating/Command.kt4
-rw-r--r--plugins/base/src/main/kotlin/templating/PathToRootSubstitutionCommand.kt3
5 files changed, 16 insertions, 2 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 16f60a83..d344dafe 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -13,6 +13,7 @@ import org.jetbrains.dokka.base.renderers.isImage
import org.jetbrains.dokka.base.renderers.pageId
import org.jetbrains.dokka.base.resolvers.anchors.SymbolAnchorHint
import org.jetbrains.dokka.base.resolvers.local.DokkaBaseLocationProvider
+import org.jetbrains.dokka.base.templating.PathToRootSubstitutionCommand
import org.jetbrains.dokka.base.templating.ResolveLinkCommand
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.DisplaySourceSet
@@ -736,7 +737,9 @@ open class HtmlRenderer(
else -> unsafe { +it }
}
}
- script { unsafe { +"""var pathToRoot = "${locationProvider.pathToRoot(page)}";""" } }
+ templateCommand(PathToRootSubstitutionCommand("###")) {
+ script { unsafe { +"""var pathToRoot = "###";""" } }
+ }
}
body {
div {
diff --git a/plugins/base/src/main/kotlin/renderers/html/Tags.kt b/plugins/base/src/main/kotlin/renderers/html/Tags.kt
index 3db49ebf..59d711e9 100644
--- a/plugins/base/src/main/kotlin/renderers/html/Tags.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/Tags.kt
@@ -13,7 +13,7 @@ open class WBR(initialAttributes: Map<String, String>, consumer: TagConsumer<*>)
HTMLTag("wbr", consumer, initialAttributes, namespace = null, inlineTag = true, emptyTag = false),
HtmlBlockInlineTag
-fun FlowOrPhrasingContent.templateCommand(data: Command, block: TemplateCommand.() -> Unit = {}): Unit =
+fun FlowOrPhrasingOrMetaDataContent.templateCommand(data: Command, block: TemplateCommand.() -> Unit = {}): Unit =
TemplateCommand(attributesMapOf("data", toJsonString(data)), consumer).visit(block)
fun <T> TagConsumer<T>.templateCommand(data: Command, block: TemplateCommand.() -> Unit = {}): T =
diff --git a/plugins/base/src/main/kotlin/resolvers/shared/PackageList.kt b/plugins/base/src/main/kotlin/resolvers/shared/PackageList.kt
index c1b76a3b..8d3b7521 100644
--- a/plugins/base/src/main/kotlin/resolvers/shared/PackageList.kt
+++ b/plugins/base/src/main/kotlin/resolvers/shared/PackageList.kt
@@ -1,6 +1,7 @@
package org.jetbrains.dokka.base.resolvers.shared
import org.jetbrains.dokka.base.renderers.PackageListService
+import java.io.File
import java.net.URL
data class PackageList(
@@ -14,6 +15,9 @@ data class PackageList(
if (offlineMode && url.protocol.toLowerCase() != "file")
return null
+ if (!File(url.file).isFile)
+ return null
+
val packageListStream = url.readContent()
val (params, packages) = packageListStream
diff --git a/plugins/base/src/main/kotlin/templating/Command.kt b/plugins/base/src/main/kotlin/templating/Command.kt
index e352ba32..0b998dee 100644
--- a/plugins/base/src/main/kotlin/templating/Command.kt
+++ b/plugins/base/src/main/kotlin/templating/Command.kt
@@ -7,3 +7,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo.Id.CLASS
@JsonTypeInfo(use= CLASS)
interface Command
+
+abstract class SubstitutionCommand: Command {
+ abstract val pattern: String
+}
diff --git a/plugins/base/src/main/kotlin/templating/PathToRootSubstitutionCommand.kt b/plugins/base/src/main/kotlin/templating/PathToRootSubstitutionCommand.kt
new file mode 100644
index 00000000..03f091c3
--- /dev/null
+++ b/plugins/base/src/main/kotlin/templating/PathToRootSubstitutionCommand.kt
@@ -0,0 +1,3 @@
+package org.jetbrains.dokka.base.templating
+
+data class PathToRootSubstitutionCommand(override val pattern: String): SubstitutionCommand() \ No newline at end of file