aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/kotlin')
-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