aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-02-09 20:12:30 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-02-09 20:12:30 +0100
commit0b6f2b22f972b8e62f1d5eece72aea93043ffb90 (patch)
treeac68446902945aaf98988c8c5ccc97d8b6ade7fb /src
parente9c1e35d583c78bf74d18ee8ae9389cd37a9f554 (diff)
downloaddokka-0b6f2b22f972b8e62f1d5eece72aea93043ffb90.tar.gz
dokka-0b6f2b22f972b8e62f1d5eece72aea93043ffb90.tar.bz2
dokka-0b6f2b22f972b8e62f1d5eece72aea93043ffb90.zip
make sure that file names generated from identifiers are unique on case-insensitive file systems
Diffstat (limited to 'src')
-rw-r--r--src/Locations/FoldersLocationService.kt2
-rw-r--r--src/Locations/LocationService.kt6
-rw-r--r--src/Locations/SingleFolderLocationService.kt2
3 files changed, 7 insertions, 3 deletions
diff --git a/src/Locations/FoldersLocationService.kt b/src/Locations/FoldersLocationService.kt
index 6bfa9446..db06dc2c 100644
--- a/src/Locations/FoldersLocationService.kt
+++ b/src/Locations/FoldersLocationService.kt
@@ -5,7 +5,7 @@ import java.io.File
public fun FoldersLocationService(root: String): FoldersLocationService = FoldersLocationService(File(root))
public class FoldersLocationService(val root: File) : LocationService {
override fun location(node: DocumentationNode): Location {
- val parts = node.path.map { escapeUri(it.name) }
+ val parts = node.path.map { identifierToFilename(it.name) }
val folder = if (node.members.none()) {
// leaf node, use file in owner's folder
parts.joinToString("/", limit = parts.size - 1, truncated = "") + "/" + parts.last()
diff --git a/src/Locations/LocationService.kt b/src/Locations/LocationService.kt
index cb0a5670..26a67382 100644
--- a/src/Locations/LocationService.kt
+++ b/src/Locations/LocationService.kt
@@ -32,7 +32,11 @@ public trait LocationService {
}
-public fun escapeUri(path: String): String = path.replace('<', '-').replace('>', '-')
+public fun identifierToFilename(path: String): String {
+ val escaped = path.replace('<', '-').replace('>', '-')
+ val lowercase = escaped.replaceAll("[A-Z]") { matchResult -> "-" + matchResult.group().toLowerCase() }
+ return if (lowercase == "index") "--index--" else lowercase
+}
/**
* Returns relative location between two nodes. Used for relative links in documentation.
diff --git a/src/Locations/SingleFolderLocationService.kt b/src/Locations/SingleFolderLocationService.kt
index 8fc6a201..4f926959 100644
--- a/src/Locations/SingleFolderLocationService.kt
+++ b/src/Locations/SingleFolderLocationService.kt
@@ -5,7 +5,7 @@ import java.io.File
public fun SingleFolderLocationService(root: String): SingleFolderLocationService = SingleFolderLocationService(File(root))
public class SingleFolderLocationService(val root: File) : LocationService {
override fun location(node: DocumentationNode): Location {
- val filename = node.path.map { escapeUri(it.name) }.joinToString("-")
+ val filename = node.path.map { identifierToFilename(it.name) }.joinToString("-")
return Location(File(root, filename))
}
} \ No newline at end of file