aboutsummaryrefslogtreecommitdiff
path: root/src/main.kt
diff options
context:
space:
mode:
authorSergey Mashkov <sergey.mashkov@jetbrains.com>2015-07-31 15:35:34 +0300
committerSergey Mashkov <sergey.mashkov@jetbrains.com>2015-07-31 17:52:49 +0300
commite27fb69817b1417c1bc556a507b14f2700c7a736 (patch)
treeb6d3b5622e65651ae6510f5109d86f834ff2c337 /src/main.kt
parent12f91ee7d491b21359ff8e8822c594f35b904def (diff)
downloaddokka-e27fb69817b1417c1bc556a507b14f2700c7a736.tar.gz
dokka-e27fb69817b1417c1bc556a507b14f2700c7a736.tar.bz2
dokka-e27fb69817b1417c1bc556a507b14f2700c7a736.zip
Use Guice injector and ServiceLocator to load implementations on the fly
Diffstat (limited to 'src/main.kt')
-rw-r--r--src/main.kt37
1 files changed, 9 insertions, 28 deletions
diff --git a/src/main.kt b/src/main.kt
index 4a0c22f8..29a22672 100644
--- a/src/main.kt
+++ b/src/main.kt
@@ -1,5 +1,6 @@
package org.jetbrains.dokka
+import com.google.inject.Guice
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.psi.PsiFile
@@ -7,6 +8,7 @@ import com.intellij.psi.PsiJavaFile
import com.intellij.psi.PsiManager
import com.sampullara.cli.Args
import com.sampullara.cli.Argument
+import org.jetbrains.dokka.Utilities.GuiceModule
import org.jetbrains.kotlin.cli.common.arguments.ValueDescription
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
@@ -17,6 +19,7 @@ import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.utils.PathUtil
import java.io.File
+import kotlin.util.measureTimeMillis
class DokkaArguments {
Argument(value = "src", description = "Source file or directory (allows many paths separated by the system path separator)")
@@ -141,8 +144,8 @@ class DokkaGenerator(val logger: DokkaLogger,
fun generate() {
val environment = createAnalysisEnvironment()
- logger.info("Module: ${moduleName}")
- logger.info("Output: ${File(outputDir).getAbsolutePath()}")
+ logger.info("Module: $moduleName")
+ logger.info("Output: ${File(outputDir).absolutePath}")
logger.info("Sources: ${environment.sources.join()}")
logger.info("Classpath: ${environment.classpath.joinToString()}")
@@ -155,34 +158,12 @@ class DokkaGenerator(val logger: DokkaLogger,
val timeAnalyse = System.currentTimeMillis() - startAnalyse
logger.info("done in ${timeAnalyse / 1000} secs")
- val startBuild = System.currentTimeMillis()
- val signatureGenerator = KotlinLanguageService()
- val locationService = FoldersLocationService(outputDir)
- val templateService = HtmlTemplateService.default("/dokka/styles/style.css")
-
- val (formatter, outlineFormatter) = when (outputFormat) {
- "html" -> {
- val htmlFormatService = HtmlFormatService(locationService, signatureGenerator, templateService)
- htmlFormatService to htmlFormatService
- }
- "markdown" -> MarkdownFormatService(locationService, signatureGenerator) to null
- "jekyll" -> JekyllFormatService(locationService.withExtension("html"), signatureGenerator) to null
- "kotlin-website" -> KotlinWebsiteFormatService(locationService.withExtension("html"), signatureGenerator) to
- YamlOutlineService(locationService, signatureGenerator)
- else -> {
- logger.error("Unrecognized output format ${outputFormat}")
- null to null
- }
+ val timeBuild = measureTimeMillis {
+ logger.info("Generating pages... ")
+ Guice.createInjector(GuiceModule(this)).getInstance(javaClass<Generator>()).buildAll(documentation)
}
- if (formatter == null) return
-
- val generator = FileGenerator(signatureGenerator, locationService.withExtension(formatter.extension),
- formatter, outlineFormatter)
- logger.info("Generating pages... ")
- generator.buildPage(documentation)
- generator.buildOutline(documentation)
- val timeBuild = System.currentTimeMillis() - startBuild
logger.info("done in ${timeBuild / 1000} secs")
+
Disposer.dispose(environment)
}