aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Generation
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-12-11 18:28:08 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-12-11 18:28:08 +0300
commit799e3713f8b6a80b53a1b9f28a86844ed30b71ae (patch)
tree4decbd8510b2e0ea3629c8db51c7d8b88652b2a7 /core/src/main/kotlin/Generation
parent6ef35accd16533c84be5d0164739b146cfb55b73 (diff)
downloaddokka-799e3713f8b6a80b53a1b9f28a86844ed30b71ae.tar.gz
dokka-799e3713f8b6a80b53a1b9f28a86844ed30b71ae.tar.bz2
dokka-799e3713f8b6a80b53a1b9f28a86844ed30b71ae.zip
Fix file extensions when FormatService.extension != linkExtension
Diffstat (limited to 'core/src/main/kotlin/Generation')
-rw-r--r--core/src/main/kotlin/Generation/FileGenerator.kt15
1 files changed, 10 insertions, 5 deletions
diff --git a/core/src/main/kotlin/Generation/FileGenerator.kt b/core/src/main/kotlin/Generation/FileGenerator.kt
index 3d25e932..bc08e180 100644
--- a/core/src/main/kotlin/Generation/FileGenerator.kt
+++ b/core/src/main/kotlin/Generation/FileGenerator.kt
@@ -2,6 +2,7 @@ package org.jetbrains.dokka
import com.google.inject.Inject
import com.google.inject.name.Named
+import org.jetbrains.kotlin.utils.fileUtils.withReplacedExtensionOrNull
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
@@ -17,22 +18,26 @@ class FileGenerator @Inject constructor(@Named("outputDir") val rootFile: File)
override val root: File = rootFile
override fun location(node: DocumentationNode): FileLocation {
- return locationWithoutExtension(node).let { it.copy(file = it.file.appendExtension(formatService.linkExtension)) }
+ return FileLocation(fileForNode(node, formatService.linkExtension))
+ }
+
+ private fun fileForNode(node: DocumentationNode, extension: String = ""): File {
+ return File(root, relativePathToNode(node)).appendExtension(extension)
}
fun locationWithoutExtension(node: DocumentationNode): FileLocation {
- return FileLocation(File(rootFile, relativePathToNode(node)))
+ return FileLocation(fileForNode(node))
}
override fun buildPages(nodes: Iterable<DocumentationNode>) {
- for ((location, items) in nodes.groupBy { location(it) }) {
- val file = location.file
+ for ((file, items) in nodes.groupBy { fileForNode(it, formatService.extension) }) {
+
file.parentFile?.mkdirsOrFail()
try {
FileOutputStream(file).use {
OutputStreamWriter(it, Charsets.UTF_8).use {
- it.write(formatService.format(location, items))
+ it.write(formatService.format(location(items.first()), items))
}
}
} catch (e: Throwable) {