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/Formats | |
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/Formats')
-rw-r--r-- | src/Formats/FormatDescriptor.kt | 11 | ||||
-rw-r--r-- | src/Formats/HtmlFormatService.kt | 6 | ||||
-rw-r--r-- | src/Formats/JekyllFormatService.kt | 4 | ||||
-rw-r--r-- | src/Formats/KotlinWebsiteFormatService.kt | 4 | ||||
-rw-r--r-- | src/Formats/MarkdownFormatService.kt | 4 | ||||
-rw-r--r-- | src/Formats/StandardFormats.kt | 47 | ||||
-rw-r--r-- | src/Formats/YamlOutlineService.kt | 3 |
7 files changed, 73 insertions, 6 deletions
diff --git a/src/Formats/FormatDescriptor.kt b/src/Formats/FormatDescriptor.kt new file mode 100644 index 00000000..beff730f --- /dev/null +++ b/src/Formats/FormatDescriptor.kt @@ -0,0 +1,11 @@ +package org.jetbrains.dokka.Formats + +import org.jetbrains.dokka.FormatService +import org.jetbrains.dokka.Generator +import org.jetbrains.dokka.OutlineFormatService + +public interface FormatDescriptor { + val formatServiceClass: Class<out FormatService>? + val outlineServiceClass: Class<out OutlineFormatService>? + val generatorServiceClass: Class<out Generator> +}
\ No newline at end of file diff --git a/src/Formats/HtmlFormatService.kt b/src/Formats/HtmlFormatService.kt index 8e38a32c..e810ef7f 100644 --- a/src/Formats/HtmlFormatService.kt +++ b/src/Formats/HtmlFormatService.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 open class HtmlFormatService(locationService: LocationService, +public open class HtmlFormatService @Inject constructor(@Named("folders") locationService: LocationService, signatureGenerator: LanguageService, - val templateService: HtmlTemplateService = HtmlTemplateService.default()) + val templateService: HtmlTemplateService) : StructuredFormatService(locationService, signatureGenerator, "html"), OutlineFormatService { override public fun formatText(text: String): String { return text.htmlEscape() diff --git a/src/Formats/JekyllFormatService.kt b/src/Formats/JekyllFormatService.kt index 98958293..75684ac2 100644 --- a/src/Formats/JekyllFormatService.kt +++ b/src/Formats/JekyllFormatService.kt @@ -1,6 +1,8 @@ package org.jetbrains.dokka -public open class JekyllFormatService(locationService: LocationService, +import com.google.inject.Inject + +public open class JekyllFormatService @Inject constructor(locationService: LocationService, signatureGenerator: LanguageService) : MarkdownFormatService(locationService, signatureGenerator) { diff --git a/src/Formats/KotlinWebsiteFormatService.kt b/src/Formats/KotlinWebsiteFormatService.kt index 71eb7753..25491cb3 100644 --- a/src/Formats/KotlinWebsiteFormatService.kt +++ b/src/Formats/KotlinWebsiteFormatService.kt @@ -1,6 +1,8 @@ package org.jetbrains.dokka -public class KotlinWebsiteFormatService(locationService: LocationService, +import com.google.inject.Inject + +public class KotlinWebsiteFormatService @Inject constructor(locationService: LocationService, signatureGenerator: LanguageService) : JekyllFormatService(locationService, signatureGenerator) { private var needHardLineBreaks = false diff --git a/src/Formats/MarkdownFormatService.kt b/src/Formats/MarkdownFormatService.kt index ba7d8f7b..29a9f5c4 100644 --- a/src/Formats/MarkdownFormatService.kt +++ b/src/Formats/MarkdownFormatService.kt @@ -1,7 +1,9 @@ package org.jetbrains.dokka +import com.google.inject.Inject -public open class MarkdownFormatService(locationService: LocationService, + +public open class MarkdownFormatService @Inject constructor(locationService: LocationService, signatureGenerator: LanguageService) : StructuredFormatService(locationService, signatureGenerator, "md") { override public fun formatBreadcrumbs(items: Iterable<FormatLink>): String { diff --git a/src/Formats/StandardFormats.kt b/src/Formats/StandardFormats.kt new file mode 100644 index 00000000..1d5ffe13 --- /dev/null +++ b/src/Formats/StandardFormats.kt @@ -0,0 +1,47 @@ +package org.jetbrains.dokka.Formats + +import org.jetbrains.dokka.* + +class HtmlFormatDescriptor : FormatDescriptor { + override val formatServiceClass: Class<out FormatService> + get() = javaClass<HtmlFormatService>() + + override val outlineServiceClass: Class<out OutlineFormatService> + get() = javaClass<HtmlFormatService>() + + override val generatorServiceClass: Class<out Generator> + get() = javaClass<FileGenerator>() +} + +class KotlinWebsiteFormatDescriptor : FormatDescriptor { + override val formatServiceClass: Class<out FormatService> + get() = javaClass<KotlinWebsiteFormatService>() + + override val outlineServiceClass: Class<out OutlineFormatService> + get() = javaClass<YamlOutlineService>() + + override val generatorServiceClass: Class<out Generator> + get() = javaClass<FileGenerator>() +} + +class JekyllFormatDescriptor : FormatDescriptor { + override val formatServiceClass: Class<out FormatService> + get() = javaClass<JekyllFormatService>() + + override val outlineServiceClass: Class<out OutlineFormatService>? + get() = null + + override val generatorServiceClass: Class<out Generator> + get() = javaClass<FileGenerator>() +} + +class MarkdownFormatDescriptor : FormatDescriptor { + override val formatServiceClass: Class<out FormatService> + get() = javaClass<MarkdownFormatService>() + + override val outlineServiceClass: Class<out OutlineFormatService>? + get() = null + + override val generatorServiceClass: Class<out Generator> + get() = javaClass<FileGenerator>() +} diff --git a/src/Formats/YamlOutlineService.kt b/src/Formats/YamlOutlineService.kt index cdab4eeb..7968824c 100644 --- a/src/Formats/YamlOutlineService.kt +++ b/src/Formats/YamlOutlineService.kt @@ -1,8 +1,9 @@ package org.jetbrains.dokka +import com.google.inject.Inject import java.io.File -class YamlOutlineService(val locationService: LocationService, +class YamlOutlineService @Inject constructor(val locationService: LocationService, val languageService: LanguageService) : OutlineFormatService { override fun getOutlineFileName(location: Location): File = File("${location.path}.yml") |