aboutsummaryrefslogtreecommitdiff
path: root/src/Locations
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-02-20 14:44:30 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-02-20 14:44:30 +0100
commitecadf405143811776f46142e7c97cc33380efb68 (patch)
treec03992fcd662e333cdc360a44a6e5d3b9ebb6120 /src/Locations
parent85a3ae7626810113816fd31a0e26d44d48308ed2 (diff)
downloaddokka-ecadf405143811776f46142e7c97cc33380efb68.tar.gz
dokka-ecadf405143811776f46142e7c97cc33380efb68.tar.bz2
dokka-ecadf405143811776f46142e7c97cc33380efb68.zip
allow a LocationService to take a qualified name directly, not just a DocumentationNode
Diffstat (limited to 'src/Locations')
-rw-r--r--src/Locations/FoldersLocationService.kt10
-rw-r--r--src/Locations/LocationService.kt10
-rw-r--r--src/Locations/SingleFolderLocationService.kt4
3 files changed, 14 insertions, 10 deletions
diff --git a/src/Locations/FoldersLocationService.kt b/src/Locations/FoldersLocationService.kt
index 4f56475c..ce202cfe 100644
--- a/src/Locations/FoldersLocationService.kt
+++ b/src/Locations/FoldersLocationService.kt
@@ -6,14 +6,14 @@ public fun FoldersLocationService(root: String): FoldersLocationService = Folder
public class FoldersLocationService(val root: File, val extension: String) : FileLocationService {
override fun withExtension(newExtension: String): LocationService = FoldersLocationService(root, newExtension)
- override fun location(node: DocumentationNode): FileLocation {
- return FileLocation(File(root, relativePathToNode(node)).appendExtension(extension))
+ override fun location(qualifiedName: List<String>, hasMembers: Boolean): FileLocation {
+ return FileLocation(File(root, relativePathToNode(qualifiedName, hasMembers)).appendExtension(extension))
}
}
-fun relativePathToNode(node: DocumentationNode): String {
- val parts = node.path.map { identifierToFilename(it.name) }.filterNot { it.isEmpty() }
- return if (node.members.none()) {
+fun relativePathToNode(qualifiedName: List<String>, hasMembers: Boolean): String {
+ val parts = qualifiedName.map { identifierToFilename(it) }.filterNot { it.isEmpty() }
+ return if (!hasMembers) {
// leaf node, use file in owner's folder
parts.joinToString("/")
} else {
diff --git a/src/Locations/LocationService.kt b/src/Locations/LocationService.kt
index 500b89f2..cb05535a 100644
--- a/src/Locations/LocationService.kt
+++ b/src/Locations/LocationService.kt
@@ -41,15 +41,19 @@ public data class FileLocation(val file: File): Location {
public trait LocationService {
fun withExtension(newExtension: String) = this
+ fun location(node: DocumentationNode): Location = location(node.path.map { it.name }, node.members.any())
+
/**
- * Calculates location for particular node in output structure
+ * Calculates a location corresponding to the specified [qualifiedName].
+ * @param hasMembers if true, the node for which the location is calculated has member nodes.
*/
- fun location(node: DocumentationNode): Location
+ fun location(qualifiedName: List<String>, hasMembers: Boolean): Location
}
public trait FileLocationService: LocationService {
- override fun location(node: DocumentationNode): FileLocation
+ override fun location(node: DocumentationNode): FileLocation = location(node.path.map { it.name }, node.members.any())
+ override fun location(qualifiedName: List<String>, hasMembers: Boolean): FileLocation
}
diff --git a/src/Locations/SingleFolderLocationService.kt b/src/Locations/SingleFolderLocationService.kt
index e136a6b2..c26d2b34 100644
--- a/src/Locations/SingleFolderLocationService.kt
+++ b/src/Locations/SingleFolderLocationService.kt
@@ -7,8 +7,8 @@ public class SingleFolderLocationService(val root: File, val extension: String)
override fun withExtension(newExtension: String): LocationService =
SingleFolderLocationService(root, newExtension)
- override fun location(node: DocumentationNode): FileLocation {
- val filename = node.path.map { identifierToFilename(it.name) }.joinToString("-")
+ override fun location(qualifiedName: List<String>, hasMembers: Boolean): FileLocation {
+ val filename = qualifiedName.map { identifierToFilename(it) }.joinToString("-")
return FileLocation(File(root, filename).appendExtension(extension))
}
} \ No newline at end of file