aboutsummaryrefslogtreecommitdiff
path: root/src/Locations/LocationService.kt
blob: 03f22d08c88442bfac1500e75fa1f0fe4c96aa17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package org.jetbrains.dokka

import java.io.File

data class Location(val file: File)

public trait LocationService {
    fun location(node: DocumentationNode): Location
}


public fun escapeUri(path: String): String = path.replace('<', '_').replace('>', '_')

fun LocationService.relativeLocation(node: DocumentationNode, link: DocumentationNode, extension: String): File {
    val ownerFolder = location(node).file.getParentFile()!!
    val memberPath = location(link).file.appendExtension(extension)
    return ownerFolder.getRelativePath(memberPath)
}