diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-26 21:17:13 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-26 21:17:13 +0100 |
commit | 4b61be354510cf88fed33860c987bd210502e91d (patch) | |
tree | 7b7bb9f317cf0edfe1cdee404b6b34ff02e39054 /src | |
parent | 11bc0b1ceef4340e7587b85b647010faf171131b (diff) | |
download | dokka-4b61be354510cf88fed33860c987bd210502e91d.tar.gz dokka-4b61be354510cf88fed33860c987bd210502e91d.tar.bz2 dokka-4b61be354510cf88fed33860c987bd210502e91d.zip |
don't generate redundant links that lead to the same page with no anchor (e.g. receiver type in extension functions)
Diffstat (limited to 'src')
-rw-r--r-- | src/Formats/StructuredFormatService.kt | 12 | ||||
-rw-r--r-- | src/Generation/FileGenerator.kt | 2 | ||||
-rw-r--r-- | src/Locations/FoldersLocationService.kt | 2 | ||||
-rw-r--r-- | src/Locations/LocationService.kt | 3 | ||||
-rw-r--r-- | src/main.kt | 3 |
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) |