aboutsummaryrefslogtreecommitdiff
path: root/src/Formats/StructuredFormatService.kt
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-02-19 18:59:00 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-02-19 18:59:00 +0100
commitd9bfa029b0ecf300ae47cf1033db2d5cb323d705 (patch)
treeff8a9f7d4b0b1233d3d7b1e89a74047c64c8dbd7 /src/Formats/StructuredFormatService.kt
parent2822a3eee07a27495d5af4fc36304d483756d3a6 (diff)
downloaddokka-d9bfa029b0ecf300ae47cf1033db2d5cb323d705.tar.gz
dokka-d9bfa029b0ecf300ae47cf1033db2d5cb323d705.tar.bz2
dokka-d9bfa029b0ecf300ae47cf1033db2d5cb323d705.zip
remove dependency of Location on a File; use more meaningful locations in tests
Diffstat (limited to 'src/Formats/StructuredFormatService.kt')
-rw-r--r--src/Formats/StructuredFormatService.kt13
1 files changed, 6 insertions, 7 deletions
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) {