diff options
4 files changed, 7 insertions, 10 deletions
diff --git a/core/src/main/kotlin/Formats/HtmlFormatService.kt b/core/src/main/kotlin/Formats/HtmlFormatService.kt index 0073553c..0ad946be 100644 --- a/core/src/main/kotlin/Formats/HtmlFormatService.kt +++ b/core/src/main/kotlin/Formats/HtmlFormatService.kt @@ -4,7 +4,6 @@ import com.google.inject.Inject import com.google.inject.name.Named import org.jetbrains.dokka.Utilities.impliedPlatformsName import java.io.File -import java.nio.file.Path open class HtmlOutputBuilder(to: StringBuilder, location: Location, @@ -80,7 +79,7 @@ open class HtmlOutputBuilder(to: StringBuilder, } override fun appendNodes(nodes: Iterable<DocumentationNode>) { - templateService.appendHeader(to, getPageTitle(nodes), generator.relativeToRoot(location)) + templateService.appendHeader(to, getPageTitle(nodes), generator.relativePathToRoot(location)) super.appendNodes(nodes) templateService.appendFooter(to) } @@ -108,7 +107,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", generator.relativeToRoot(location)) + templateService.appendHeader(to, "Module Contents", generator.relativePathToRoot(location)) super.appendOutline(location, to, nodes) templateService.appendFooter(to) } diff --git a/core/src/main/kotlin/Generation/FileGenerator.kt b/core/src/main/kotlin/Generation/FileGenerator.kt index bc08e180..b7c6cf63 100644 --- a/core/src/main/kotlin/Generation/FileGenerator.kt +++ b/core/src/main/kotlin/Generation/FileGenerator.kt @@ -8,15 +8,13 @@ import java.io.FileOutputStream import java.io.IOException import java.io.OutputStreamWriter -class FileGenerator @Inject constructor(@Named("outputDir") val rootFile: File) : NodeLocationAwareGenerator { +class FileGenerator @Inject constructor(@Named("outputDir") override val root: File) : NodeLocationAwareGenerator { @set:Inject(optional = true) var outlineService: OutlineFormatService? = null @set:Inject(optional = true) lateinit var formatService: FormatService @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(fileForNode(node, formatService.linkExtension)) } diff --git a/core/src/main/kotlin/Locations/Location.kt b/core/src/main/kotlin/Locations/Location.kt index 0e6572d9..4cb0ac39 100644 --- a/core/src/main/kotlin/Locations/Location.kt +++ b/core/src/main/kotlin/Locations/Location.kt @@ -53,9 +53,9 @@ fun NodeLocationAwareGenerator.relativePathToLocation(owner: DocumentationNode, return location(owner).relativePathTo(location(node), null) } -fun NodeLocationAwareGenerator.relativeToRoot(from: Location): File { - val file = File(from.path) - return file.relativeTo(root) +fun NodeLocationAwareGenerator.relativePathToRoot(from: Location): File { + val file = File(from.path).parentFile + return root.relativeTo(file) } fun File.toUnixString() = toString().replace(File.separatorChar, '/') diff --git a/core/src/test/kotlin/format/FileGeneratorTestCase.kt b/core/src/test/kotlin/format/FileGeneratorTestCase.kt index 948426ea..ef9e815d 100644 --- a/core/src/test/kotlin/format/FileGeneratorTestCase.kt +++ b/core/src/test/kotlin/format/FileGeneratorTestCase.kt @@ -27,7 +27,7 @@ abstract class FileGeneratorTestCase { if (sb.isNotBlank() && !sb.endsWith('\n')) { sb.appendln() } - sb.appendln("<!-- File: ${relativeToRoot(loc).toUnixString()} -->") + sb.appendln("<!-- File: ${loc.file.relativeTo(root).toUnixString()} -->") } sb.append(loc.file.readText()) } |