aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/Formats/HtmlFormatService.kt9
-rw-r--r--core/src/main/kotlin/Formats/HtmlTemplateService.kt6
-rw-r--r--core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt4
-rw-r--r--core/src/main/kotlin/Generation/FileGenerator.kt2
-rw-r--r--core/src/main/kotlin/Generation/Generator.kt3
-rw-r--r--core/src/main/kotlin/Locations/LocationService.kt6
6 files changed, 18 insertions, 12 deletions
diff --git a/core/src/main/kotlin/Formats/HtmlFormatService.kt b/core/src/main/kotlin/Formats/HtmlFormatService.kt
index 560d8597..0073553c 100644
--- a/core/src/main/kotlin/Formats/HtmlFormatService.kt
+++ b/core/src/main/kotlin/Formats/HtmlFormatService.kt
@@ -80,7 +80,7 @@ open class HtmlOutputBuilder(to: StringBuilder,
}
override fun appendNodes(nodes: Iterable<DocumentationNode>) {
- templateService.appendHeader(to, getPageTitle(nodes), locationService.calcPathToRoot(location))
+ templateService.appendHeader(to, getPageTitle(nodes), generator.relativeToRoot(location))
super.appendNodes(nodes)
templateService.appendFooter(to)
}
@@ -108,7 +108,7 @@ open class HtmlFormatService @Inject constructor(generator: NodeLocationAwareGen
HtmlOutputBuilder(to, location, generator, languageService, extension, impliedPlatforms, templateService)
override fun appendOutline(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) {
- templateService.appendHeader(to, "Module Contents", locationService.calcPathToRoot(location))
+ templateService.appendHeader(to, "Module Contents", generator.relativeToRoot(location))
super.appendOutline(location, to, nodes)
templateService.appendFooter(to)
}
@@ -132,11 +132,6 @@ open class HtmlFormatService @Inject constructor(generator: NodeLocationAwareGen
}
}
-private fun LocationService.calcPathToRoot(location: Location): Path {
- val path = Paths.get(location.path)
- return path.parent?.relativize(Paths.get(root.path + '/')) ?: path
-}
-
fun getPageTitle(nodes: Iterable<DocumentationNode>): String? {
val breakdownByLocation = nodes.groupBy { node -> formatPageTitle(node) }
return breakdownByLocation.keys.singleOrNull()
diff --git a/core/src/main/kotlin/Formats/HtmlTemplateService.kt b/core/src/main/kotlin/Formats/HtmlTemplateService.kt
index 22832e34..84e01910 100644
--- a/core/src/main/kotlin/Formats/HtmlTemplateService.kt
+++ b/core/src/main/kotlin/Formats/HtmlTemplateService.kt
@@ -1,9 +1,9 @@
package org.jetbrains.dokka
-import java.nio.file.Path
+import java.io.File
interface HtmlTemplateService {
- fun appendHeader(to: StringBuilder, title: String?, basePath: Path)
+ fun appendHeader(to: StringBuilder, title: String?, basePath: File)
fun appendFooter(to: StringBuilder)
companion object {
@@ -16,7 +16,7 @@ interface HtmlTemplateService {
to.appendln("</BODY>")
to.appendln("</HTML>")
}
- override fun appendHeader(to: StringBuilder, title: String?, relativePathToRoot: String) {
+ override fun appendHeader(to: StringBuilder, title: String?, basePath: File) {
to.appendln("<HTML>")
to.appendln("<HEAD>")
to.appendln("<meta charset=\"UTF-8\">")
diff --git a/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt b/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt
index 208756c8..6ced75b5 100644
--- a/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt
+++ b/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt
@@ -4,13 +4,13 @@ import com.google.inject.Inject
import com.google.inject.name.Named
import org.jetbrains.dokka.Utilities.impliedPlatformsName
import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty
-import java.nio.file.Path
+import java.io.File
object EmptyHtmlTemplateService : HtmlTemplateService {
override fun appendFooter(to: StringBuilder) {}
- override fun appendHeader(to: StringBuilder, title: String?, basePath: Path) {}
+ override fun appendHeader(to: StringBuilder, title: String?, basePath: File) {}
}
diff --git a/core/src/main/kotlin/Generation/FileGenerator.kt b/core/src/main/kotlin/Generation/FileGenerator.kt
index 3193a5bc..9c7c65e6 100644
--- a/core/src/main/kotlin/Generation/FileGenerator.kt
+++ b/core/src/main/kotlin/Generation/FileGenerator.kt
@@ -14,6 +14,8 @@ class FileGenerator @Inject constructor(@Named("outputDir") val rootFile: File)
@set:Inject(optional = true) lateinit var options: DocumentationOptions
@set:Inject(optional = true) var packageListService: PackageListService? = null
+ override val root: File = rootFile
+
override fun location(node: DocumentationNode): FileLocation {
return FileLocation(File(rootFile, relativePathToNode(node.path.map { it.name }, node.members.any())).appendExtension(formatService.extension))
}
diff --git a/core/src/main/kotlin/Generation/Generator.kt b/core/src/main/kotlin/Generation/Generator.kt
index 003386ef..23286e29 100644
--- a/core/src/main/kotlin/Generation/Generator.kt
+++ b/core/src/main/kotlin/Generation/Generator.kt
@@ -1,5 +1,7 @@
package org.jetbrains.dokka
+import java.io.File
+
interface Generator {
fun buildPages(nodes: Iterable<DocumentationNode>)
fun buildOutlines(nodes: Iterable<DocumentationNode>)
@@ -23,4 +25,5 @@ fun Generator.buildAll(node: DocumentationNode): Unit = buildAll(listOf(node))
interface NodeLocationAwareGenerator: Generator {
fun location(node: DocumentationNode): Location
+ val root: File
} \ No newline at end of file
diff --git a/core/src/main/kotlin/Locations/LocationService.kt b/core/src/main/kotlin/Locations/LocationService.kt
index 6b7e0511..8ea45dae 100644
--- a/core/src/main/kotlin/Locations/LocationService.kt
+++ b/core/src/main/kotlin/Locations/LocationService.kt
@@ -94,4 +94,10 @@ fun identifierToFilename(path: String): String {
fun NodeLocationAwareGenerator.relativePathToLocation(owner: DocumentationNode, node: DocumentationNode): String {
return location(owner).relativePathTo(location(node), null)
+}
+
+
+fun NodeLocationAwareGenerator.relativeToRoot(from: Location): File {
+ val file = File(from.path)
+ return file.relativeTo(root)
} \ No newline at end of file