aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2020-01-22 13:51:59 +0100
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-01-31 15:07:06 +0100
commit0e937a192adfb7097ad38e47c10fc6ee83982b6c (patch)
tree3a2d9b108449211a6679c2f8f578706c201df9cb /core/src
parent885ecd28153b484277c9ddcbf4a7f9d761a59545 (diff)
downloaddokka-0e937a192adfb7097ad38e47c10fc6ee83982b6c.tar.gz
dokka-0e937a192adfb7097ad38e47c10fc6ee83982b6c.tar.bz2
dokka-0e937a192adfb7097ad38e47c10fc6ee83982b6c.zip
Fix TestRunner with new FileWriter.kt
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/kotlin/renderers/FileWriter.kt19
-rw-r--r--core/src/main/kotlin/transformers/psi/DefaultPsiToDocumentationTranslator.kt5
2 files changed, 21 insertions, 3 deletions
diff --git a/core/src/main/kotlin/renderers/FileWriter.kt b/core/src/main/kotlin/renderers/FileWriter.kt
index 2fba649d..996fadc8 100644
--- a/core/src/main/kotlin/renderers/FileWriter.kt
+++ b/core/src/main/kotlin/renderers/FileWriter.kt
@@ -5,8 +5,9 @@ import java.io.IOException
import java.net.URI
import java.nio.file.*
-class FileWriter(val root: String, override val extension: String): OutputWriter {
+class FileWriter(val root: String, override val extension: String) : OutputWriter {
private val createdFiles: MutableSet<String> = mutableSetOf()
+ private val jarUriPrefix = "jar:file:"
override fun write(path: String, text: String, ext: String) {
if (createdFiles.contains(path)) {
@@ -25,7 +26,21 @@ class FileWriter(val root: String, override val extension: String): OutputWriter
}
}
- override fun writeResources(pathFrom: String, pathTo: String) {
+ override fun writeResources(pathFrom: String, pathTo: String) =
+ if (javaClass.getResource(pathFrom).toURI().toString().startsWith(jarUriPrefix)) {
+ copyFromJar(pathFrom, pathTo)
+ } else {
+ copyFromDirectory(pathFrom, pathTo)
+ }
+
+
+ private fun copyFromDirectory(pathFrom: String, pathTo: String) {
+ val dest = Paths.get(root, pathTo).toFile()
+ val uri = javaClass.getResource(pathFrom).toURI()
+ File(uri).copyRecursively(dest, true)
+ }
+
+ private fun copyFromJar(pathFrom: String, pathTo: String) {
val rebase = fun(path: String) =
"$pathTo/${path.removePrefix(pathFrom)}"
val dest = Paths.get(root, pathTo).toFile()
diff --git a/core/src/main/kotlin/transformers/psi/DefaultPsiToDocumentationTranslator.kt b/core/src/main/kotlin/transformers/psi/DefaultPsiToDocumentationTranslator.kt
index d8595ad3..6aff21b3 100644
--- a/core/src/main/kotlin/transformers/psi/DefaultPsiToDocumentationTranslator.kt
+++ b/core/src/main/kotlin/transformers/psi/DefaultPsiToDocumentationTranslator.kt
@@ -3,7 +3,10 @@ package org.jetbrains.dokka.transformers.psi
import com.intellij.psi.*
import com.intellij.psi.impl.source.PsiClassReferenceType
import org.jetbrains.dokka.JavadocParser
-import org.jetbrains.dokka.links.*
+import org.jetbrains.dokka.links.Callable
+import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.links.JavaClassReference
+import org.jetbrains.dokka.links.withClass
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.Function
import org.jetbrains.dokka.pages.PlatformData