diff options
author | Sergey Mashkov <sergey.mashkov@jetbrains.com> | 2015-07-31 15:35:34 +0300 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-10-29 13:21:47 +0100 |
commit | c9d59e9ae85f76e021d53c77ef18bfce0ff7ec7c (patch) | |
tree | d5e86994c762318008f7beaf781cdeafde573802 /src/Locations | |
parent | ff77b8e0ad0b5089e940227dfdd94ba21cfc6bd8 (diff) | |
download | dokka-c9d59e9ae85f76e021d53c77ef18bfce0ff7ec7c.tar.gz dokka-c9d59e9ae85f76e021d53c77ef18bfce0ff7ec7c.tar.bz2 dokka-c9d59e9ae85f76e021d53c77ef18bfce0ff7ec7c.zip |
Use Guice injector and ServiceLocator to load implementations on the fly
Diffstat (limited to 'src/Locations')
-rw-r--r-- | src/Locations/FoldersLocationService.kt | 5 | ||||
-rw-r--r-- | src/Locations/LocationService.kt | 2 | ||||
-rw-r--r-- | src/Locations/SingleFolderLocationService.kt | 6 |
3 files changed, 10 insertions, 3 deletions
diff --git a/src/Locations/FoldersLocationService.kt b/src/Locations/FoldersLocationService.kt index e85c2c98..8a0cf6be 100644 --- a/src/Locations/FoldersLocationService.kt +++ b/src/Locations/FoldersLocationService.kt @@ -1,9 +1,12 @@ package org.jetbrains.dokka +import com.google.inject.Inject +import com.google.inject.name.Named import java.io.File public fun FoldersLocationService(root: String): FoldersLocationService = FoldersLocationService(File(root), "") -public class FoldersLocationService(val root: File, val extension: String) : FileLocationService { +public class FoldersLocationService @Inject constructor(@Named("outputDir") val root: File, val extension: String) : FileLocationService { + override fun withExtension(newExtension: String): FileLocationService { return if (extension.isEmpty()) FoldersLocationService(root, newExtension) else this } diff --git a/src/Locations/LocationService.kt b/src/Locations/LocationService.kt index a43054ce..4f587361 100644 --- a/src/Locations/LocationService.kt +++ b/src/Locations/LocationService.kt @@ -55,6 +55,8 @@ public interface LocationService { public interface FileLocationService: LocationService { + override fun withExtension(newExtension: String): FileLocationService = this + 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 c26d2b34..049636c0 100644 --- a/src/Locations/SingleFolderLocationService.kt +++ b/src/Locations/SingleFolderLocationService.kt @@ -1,10 +1,12 @@ package org.jetbrains.dokka +import com.google.inject.Inject +import com.google.inject.name.Named import java.io.File public fun SingleFolderLocationService(root: String): SingleFolderLocationService = SingleFolderLocationService(File(root), "") -public class SingleFolderLocationService(val root: File, val extension: String) : FileLocationService { - override fun withExtension(newExtension: String): LocationService = +public class SingleFolderLocationService @Inject constructor(@Named("outputDir") val root: File, val extension: String) : FileLocationService { + override fun withExtension(newExtension: String): FileLocationService = SingleFolderLocationService(root, newExtension) override fun location(qualifiedName: List<String>, hasMembers: Boolean): FileLocation { |