aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Formats/StructuredFormatService.kt12
-rw-r--r--src/Generation/FileGenerator.kt2
-rw-r--r--src/Locations/FoldersLocationService.kt2
-rw-r--r--src/Locations/LocationService.kt3
-rw-r--r--src/main.kt3
5 files changed, 17 insertions, 5 deletions
diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt
index 70b2a3c1..dd23b7b3 100644
--- a/src/Formats/StructuredFormatService.kt
+++ b/src/Formats/StructuredFormatService.kt
@@ -61,11 +61,19 @@ public abstract class StructuredFormatService(locationService: LocationService,
val node = content.node
val linkTo = if (node != null) locationHref(location, node) else "#"
val linkText = formatText(location, content.children)
- append(formatLink(linkText, linkTo))
+ if (linkTo == ".") {
+ append(linkText)
+ } else {
+ append(formatLink(linkText, linkTo))
+ }
}
is ContentExternalLink -> {
val linkText = formatText(location, content.children)
- append(formatLink(linkText, content.href))
+ if (content.href == ".") {
+ append(linkText)
+ } else {
+ append(formatLink(linkText, content.href))
+ }
}
is ContentParagraph -> {
appendParagraph(this, formatText(location, content.children))
diff --git a/src/Generation/FileGenerator.kt b/src/Generation/FileGenerator.kt
index 22090937..abe4257f 100644
--- a/src/Generation/FileGenerator.kt
+++ b/src/Generation/FileGenerator.kt
@@ -13,7 +13,7 @@ public class FileGenerator(val signatureGenerator: LanguageService,
public fun buildPages(nodes: Iterable<DocumentationNode>) {
for ((location, items) in nodes.groupBy { locationService.location(it) }) {
- val file = location.file.appendExtension(formatService.extension)
+ val file = location.file
file.getParentFile()?.mkdirs()
FileOutputStream(file).use {
OutputStreamWriter(it, Charsets.UTF_8).use {
diff --git a/src/Locations/FoldersLocationService.kt b/src/Locations/FoldersLocationService.kt
index 2e9a9cd5..e85c2c98 100644
--- a/src/Locations/FoldersLocationService.kt
+++ b/src/Locations/FoldersLocationService.kt
@@ -4,7 +4,7 @@ import java.io.File
public fun FoldersLocationService(root: String): FoldersLocationService = FoldersLocationService(File(root), "")
public class FoldersLocationService(val root: File, val extension: String) : FileLocationService {
- override fun withExtension(newExtension: String): LocationService {
+ override fun withExtension(newExtension: String): FileLocationService {
return if (extension.isEmpty()) FoldersLocationService(root, newExtension) else this
}
diff --git a/src/Locations/LocationService.kt b/src/Locations/LocationService.kt
index cb05535a..2c93ba8f 100644
--- a/src/Locations/LocationService.kt
+++ b/src/Locations/LocationService.kt
@@ -23,6 +23,9 @@ public data class FileLocation(val file: File): Location {
if (other !is FileLocation) {
throw IllegalArgumentException("$other is not a FileLocation")
}
+ if (file.path.substringBeforeLast(".") == other.file.path.substringBeforeLast(".") && anchor == null) {
+ return "."
+ }
val ownerFolder = file.getParentFile()!!
val relativePath = ownerFolder.getRelativePath(other.file).path
return if (anchor == null) relativePath else relativePath + "#" + anchor
diff --git a/src/main.kt b/src/main.kt
index 3192d711..d7ff749c 100644
--- a/src/main.kt
+++ b/src/main.kt
@@ -151,7 +151,8 @@ class DokkaGenerator(val logger: DokkaLogger,
}
if (formatter == null) return
- val generator = FileGenerator(signatureGenerator, locationService, formatter, outlineFormatter)
+ val generator = FileGenerator(signatureGenerator, locationService.withExtension(formatter.extension),
+ formatter, outlineFormatter)
logger.info("Generating pages... ")
generator.buildPage(documentation)
generator.buildOutline(documentation)