aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/Generation/DokkaGenerator.kt39
-rw-r--r--core/src/main/kotlin/Utilities/DokkaModules.kt (renamed from core/src/main/kotlin/Utilities/DokkaModule.kt)48
-rw-r--r--core/src/test/kotlin/TestAPI.kt7
3 files changed, 59 insertions, 35 deletions
diff --git a/core/src/main/kotlin/Generation/DokkaGenerator.kt b/core/src/main/kotlin/Generation/DokkaGenerator.kt
index 360965d5..aaf0deff 100644
--- a/core/src/main/kotlin/Generation/DokkaGenerator.kt
+++ b/core/src/main/kotlin/Generation/DokkaGenerator.kt
@@ -7,7 +7,8 @@ import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiJavaFile
import com.intellij.psi.PsiManager
-import org.jetbrains.dokka.Utilities.DokkaModule
+import org.jetbrains.dokka.Utilities.DokkaAnalysisModule
+import org.jetbrains.dokka.Utilities.DokkaOutputModule
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
@@ -28,7 +29,21 @@ class DokkaGenerator(val logger: DokkaLogger,
val includes: List<String>,
val moduleName: String,
val options: DocumentationOptions) {
+
+ private val documentationModule = DocumentationModule(moduleName)
+
fun generate() {
+ appendSourceModule()
+
+ val timeBuild = measureTimeMillis {
+ logger.info("Generating pages... ")
+ val outputInjector = Guice.createInjector(DokkaOutputModule(options, logger))
+ outputInjector.getInstance(Generator::class.java).buildAll(documentationModule)
+ }
+ logger.info("done in ${timeBuild / 1000} secs")
+ }
+
+ private fun appendSourceModule() {
val environment = createAnalysisEnvironment()
logger.info("Module: $moduleName")
@@ -39,19 +54,13 @@ class DokkaGenerator(val logger: DokkaLogger,
logger.info("Analysing sources and libraries... ")
val startAnalyse = System.currentTimeMillis()
- val injector = Guice.createInjector(DokkaModule(environment, options, logger))
+ val injector = Guice.createInjector(DokkaAnalysisModule(environment, options, logger))
- val documentation = buildDocumentationModule(injector, moduleName, { isSample(it) }, includes)
+ buildDocumentationModule(injector, documentationModule, { isSample(it) }, includes)
val timeAnalyse = System.currentTimeMillis() - startAnalyse
logger.info("done in ${timeAnalyse / 1000} secs")
- val timeBuild = measureTimeMillis {
- logger.info("Generating pages... ")
- injector.getInstance(Generator::class.java).buildAll(documentation)
- }
- logger.info("done in ${timeBuild / 1000} secs")
-
Disposer.dispose(environment)
}
@@ -100,9 +109,9 @@ class DokkaMessageCollector(val logger: DokkaLogger): MessageCollector {
}
fun buildDocumentationModule(injector: Injector,
- moduleName: String,
+ documentationModule: DocumentationModule,
filesToDocumentFilter: (PsiFile) -> Boolean = { file -> true },
- includes: List<String> = listOf()): DocumentationModule {
+ includes: List<String> = listOf()) {
val coreEnvironment = injector.getInstance(KotlinCoreEnvironment::class.java)
val fragmentFiles = coreEnvironment.getSourceFiles().filter(filesToDocumentFilter)
@@ -120,7 +129,11 @@ fun buildDocumentationModule(injector: Injector,
for (include in includes) {
packageDocs.parse(include, fragments.firstOrNull())
}
- val documentationModule = DocumentationModule(moduleName, packageDocs.moduleContent)
+ documentationModule.updateContent {
+ for (node in packageDocs.moduleContent.children) {
+ append(node)
+ }
+ }
with(injector.getInstance(DocumentationBuilder::class.java)) {
documentationModule.appendFragments(fragments, packageDocs.packageContent,
@@ -133,8 +146,6 @@ fun buildDocumentationModule(injector: Injector,
}
injector.getInstance(NodeReferenceGraph::class.java).resolveReferences()
-
- return documentationModule
}
diff --git a/core/src/main/kotlin/Utilities/DokkaModule.kt b/core/src/main/kotlin/Utilities/DokkaModules.kt
index e1ae829a..69facaa0 100644
--- a/core/src/main/kotlin/Utilities/DokkaModule.kt
+++ b/core/src/main/kotlin/Utilities/DokkaModules.kt
@@ -10,10 +10,37 @@ import org.jetbrains.dokka.Samples.SampleProcessingService
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import java.io.File
-class DokkaModule(val environment: AnalysisEnvironment,
- val options: DocumentationOptions,
- val logger: DokkaLogger) : Module {
+class DokkaAnalysisModule(val environment: AnalysisEnvironment,
+ val options: DocumentationOptions,
+ val logger: DokkaLogger) : Module {
override fun configure(binder: Binder) {
+ val descriptor = ServiceLocator.lookup<FormatDescriptor>("format", options.outputFormat)
+
+ binder.registerCategory<LanguageService>("language")
+ binder.bind<PackageDocumentationBuilder>().to(descriptor.packageDocumentationBuilderClass.java)
+ binder.bind<JavaDocumentationBuilder>().to(descriptor.javaDocumentationBuilderClass.java)
+ binder.bind<SampleProcessingService>().to(descriptor.sampleProcessingService.java)
+
+ val coreEnvironment = environment.createCoreEnvironment()
+ binder.bind<KotlinCoreEnvironment>().toInstance(coreEnvironment)
+
+ val dokkaResolutionFacade = environment.createResolutionFacade(coreEnvironment)
+ binder.bind<DokkaResolutionFacade>().toInstance(dokkaResolutionFacade)
+
+ binder.bind<DocumentationOptions>().toInstance(options)
+ binder.bind<DokkaLogger>().toInstance(logger)
+ }
+}
+
+class DokkaOutputModule(val options: DocumentationOptions,
+ val logger: DokkaLogger) : Module {
+ override fun configure(binder: Binder) {
+ binder.bind(LanguageService::class.java).to(KotlinLanguageService::class.java)
+
+ binder.bind(HtmlTemplateService::class.java).toProvider(object : Provider<HtmlTemplateService> {
+ override fun get(): HtmlTemplateService = HtmlTemplateService.default("style.css")
+ })
+
binder.bind(File::class.java).annotatedWith(Names.named("outputDir")).toInstance(File(options.outputDir))
binder.bindNameAnnotated<LocationService, SingleFolderLocationService>("singleFolder")
@@ -24,13 +51,7 @@ class DokkaModule(val environment: AnalysisEnvironment,
// defaults
binder.bind(LocationService::class.java).to(FoldersLocationService::class.java)
binder.bind(FileLocationService::class.java).to(FoldersLocationService::class.java)
- binder.bind(LanguageService::class.java).to(KotlinLanguageService::class.java)
-
- binder.bind(HtmlTemplateService::class.java).toProvider(object : Provider<HtmlTemplateService> {
- override fun get(): HtmlTemplateService = HtmlTemplateService.default("style.css")
- })
- binder.registerCategory<LanguageService>("language")
binder.registerCategory<OutlineFormatService>("outline")
binder.registerCategory<FormatService>("format")
binder.registerCategory<Generator>("generator")
@@ -43,18 +64,9 @@ class DokkaModule(val environment: AnalysisEnvironment,
descriptor.formatServiceClass?.let { clazz ->
binder.bind(FormatService::class.java).to(clazz.java)
}
- binder.bind<PackageDocumentationBuilder>().to(descriptor.packageDocumentationBuilderClass.java)
- binder.bind<JavaDocumentationBuilder>().to(descriptor.javaDocumentationBuilderClass.java)
- binder.bind<SampleProcessingService>().to(descriptor.sampleProcessingService.java)
binder.bind<Generator>().to(descriptor.generatorServiceClass.java)
- val coreEnvironment = environment.createCoreEnvironment()
- binder.bind<KotlinCoreEnvironment>().toInstance(coreEnvironment)
-
- val dokkaResolutionFacade = environment.createResolutionFacade(coreEnvironment)
- binder.bind<DokkaResolutionFacade>().toInstance(dokkaResolutionFacade)
-
binder.bind<DocumentationOptions>().toInstance(options)
binder.bind<DokkaLogger>().toInstance(logger)
}
diff --git a/core/src/test/kotlin/TestAPI.kt b/core/src/test/kotlin/TestAPI.kt
index 7197d2c4..108c5bbf 100644
--- a/core/src/test/kotlin/TestAPI.kt
+++ b/core/src/test/kotlin/TestAPI.kt
@@ -5,7 +5,7 @@ import com.intellij.openapi.application.PathManager
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.io.FileUtil
import org.jetbrains.dokka.*
-import org.jetbrains.dokka.Utilities.DokkaModule
+import org.jetbrains.dokka.Utilities.DokkaAnalysisModule
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
@@ -65,8 +65,9 @@ fun verifyModel(vararg roots: ContentRoot,
skipEmptyPackages = false,
sourceLinks = listOf<SourceLinkDefinition>(),
generateIndexPages = false)
- val injector = Guice.createInjector(DokkaModule(environment, options, DokkaConsoleLogger))
- val documentation = buildDocumentationModule(injector, "test")
+ val injector = Guice.createInjector(DokkaAnalysisModule(environment, options, DokkaConsoleLogger))
+ val documentation = DocumentationModule("test")
+ buildDocumentationModule(injector, documentation)
verifier(documentation)
Disposer.dispose(environment)
}