diff options
Diffstat (limited to 'src/Formats')
-rw-r--r-- | src/Formats/HtmlFormatService.kt | 6 | ||||
-rw-r--r-- | src/Formats/KotlinWebsiteFormatService.kt | 3 | ||||
-rw-r--r-- | src/Formats/MarkdownFormatService.kt | 4 | ||||
-rw-r--r-- | src/Formats/StructuredFormatService.kt | 13 |
4 files changed, 10 insertions, 16 deletions
diff --git a/src/Formats/HtmlFormatService.kt b/src/Formats/HtmlFormatService.kt index 3415bfd7..8442c66f 100644 --- a/src/Formats/HtmlFormatService.kt +++ b/src/Formats/HtmlFormatService.kt @@ -82,10 +82,6 @@ public open class HtmlFormatService(locationService: LocationService, to.appendln("</td>") } - override fun formatLink(text: String, location: Location): String { - return "<a href=\"${location.path}\">${text}</a>" - } - override fun formatLink(text: String, href: String): String { return "<a href=\"${href}\">${text}</a>" } @@ -139,7 +135,7 @@ public open class HtmlFormatService(locationService: LocationService, val link = ContentNodeLink(node) link.append(languageService.render(node, LanguageService.RenderMode.FULL)) val signature = formatText(location, link) - to.appendln("${formatLink(signature, location)}<br/>") + to.appendln("<a href=\"${location.path}\">${signature}</a><br/>") } override fun appendOutlineLevel(to: StringBuilder, body: () -> Unit) { diff --git a/src/Formats/KotlinWebsiteFormatService.kt b/src/Formats/KotlinWebsiteFormatService.kt index 4f7a013a..5e616fad 100644 --- a/src/Formats/KotlinWebsiteFormatService.kt +++ b/src/Formats/KotlinWebsiteFormatService.kt @@ -22,6 +22,8 @@ public class KotlinWebsiteFormatService(locationService: LocationService, return "" } + /* + TODO this should be a LocationService override fun formatLink(text: String, location: Location): String { val href = location.path.replace("\\", "/") .replaceAfterLast(".", "html") @@ -29,6 +31,7 @@ public class KotlinWebsiteFormatService(locationService: LocationService, return "<a href=\"${href}\">${text}</a>" } + */ override fun formatLink(text: String, href: String): String { return "<a href=\"${href}\">${text}</a>" diff --git a/src/Formats/MarkdownFormatService.kt b/src/Formats/MarkdownFormatService.kt index 3598f29d..b855ec9c 100644 --- a/src/Formats/MarkdownFormatService.kt +++ b/src/Formats/MarkdownFormatService.kt @@ -50,10 +50,6 @@ public open class MarkdownFormatService(locationService: LocationService, return "~~$text~~" } - override public fun formatLink(text: String, location: Location): String { - return "[$text](${location.path})" - } - override fun formatLink(text: String, href: String): String { return "[$text]($href)" } diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index 10650ab2..32e22fd7 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -3,7 +3,7 @@ package org.jetbrains.dokka import java.util.LinkedHashMap import org.jetbrains.dokka.LanguageService.RenderMode -public data class FormatLink(val text: String, val location: Location) +public data class FormatLink(val text: String, val href: String) public abstract class StructuredFormatService(val locationService: LocationService, val languageService: LanguageService) : FormatService { @@ -25,9 +25,8 @@ public abstract class StructuredFormatService(val locationService: LocationServi public abstract fun formatSymbol(text: String): String public abstract fun formatKeyword(text: String): String public abstract fun formatIdentifier(text: String): String - public abstract fun formatLink(text: String, location: Location): String public abstract fun formatLink(text: String, href: String): String - public open fun formatLink(link: FormatLink): String = formatLink(formatText(link.text), link.location) + public open fun formatLink(link: FormatLink): String = formatLink(formatText(link.text), link.href) public abstract fun formatStrong(text: String): String public abstract fun formatStrikethrough(text: String): String public abstract fun formatEmphasis(text: String): String @@ -55,7 +54,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi is ContentListItem -> append(formatListItem(formatText(location, content.children))) is ContentNodeLink -> { - val linkTo = locationService.relativeLocation(location, content.node, extension) + val linkTo = location.relativePathTo(locationService.location(content.node), extension) val linkText = formatText(location, content.children) append(formatLink(linkText, linkTo)) } @@ -77,7 +76,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi open public fun link(from: DocumentationNode, to: DocumentationNode): FormatLink = link(from, to, extension) open public fun link(from: DocumentationNode, to: DocumentationNode, extension: String): FormatLink { - return FormatLink(to.name, locationService.relativeLocation(from, to, extension)) + return FormatLink(to.name, locationService.relativePathToLocation(from, to, extension)) } fun appendDocumentation(location: Location, to: StringBuilder, overloads: Iterable<DocumentationNode>) { @@ -133,7 +132,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi private fun DocumentationNode.appendOverrides(to: StringBuilder) { overrides.forEach { to.append("Overrides ") - val location = locationService.relativeLocation(this, it, extension) + val location = locationService.relativePathToLocation(this, it, extension) appendLine(to, formatLink(FormatLink(it.owner!!.name + "." + it.name, location))) } } @@ -210,7 +209,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi override fun appendNodes(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) { val breakdownByLocation = nodes.groupBy { node -> - formatBreadcrumbs(node.path.map { link(node, it) }) + formatBreadcrumbs(node.path.filterNot { it.name.isEmpty() }.map { link(node, it) }) } for ((breadcrumbs, items) in breakdownByLocation) { |