diff options
author | Paweł Marks <pmarks@virtuslab.com> | 2019-10-31 22:58:42 +0100 |
---|---|---|
committer | Paweł Marks <pmarks@virtuslab.com> | 2019-10-31 22:58:42 +0100 |
commit | 5f36bdd75e32743f54193aa8eff8cd5185b3cf67 (patch) | |
tree | 51c148449cfec75b455bea34eba89aed0189ebf6 /core/src/main/kotlin/DokkaGenerator.kt | |
parent | 2f293770a61220b7ab3a26ea459c4a52501ec053 (diff) | |
download | dokka-5f36bdd75e32743f54193aa8eff8cd5185b3cf67.tar.gz dokka-5f36bdd75e32743f54193aa8eff8cd5185b3cf67.tar.bz2 dokka-5f36bdd75e32743f54193aa8eff8cd5185b3cf67.zip |
Adds transformation from descriptors to documentation graph
Diffstat (limited to 'core/src/main/kotlin/DokkaGenerator.kt')
-rw-r--r-- | core/src/main/kotlin/DokkaGenerator.kt | 59 |
1 files changed, 54 insertions, 5 deletions
diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt index abb6f069..f1aa7b71 100644 --- a/core/src/main/kotlin/DokkaGenerator.kt +++ b/core/src/main/kotlin/DokkaGenerator.kt @@ -1,13 +1,62 @@ package org.jetbrains.dokka +import kotlinx.html.DD +import org.jetbrains.dokka.Model.Module +import org.jetbrains.dokka.Utilities.pretty +import org.jetbrains.dokka.links.DRI +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.cli.common.messages.MessageRenderer +import org.jetbrains.kotlin.utils.PathUtil +import java.io.File + class DokkaGenerator( - private val configurationWithLinks: DokkaConfiguration, + private val configuration: DokkaConfiguration, private val logger: DokkaLogger ) { - fun generate() { - println("RUNNED") - logger.error("runned") - throw AssertionError() + fun generate() = configuration.passesConfigurations.forEach { pass -> + AnalysisEnvironment(DokkaMessageCollector(logger), pass.analysisPlatform).run { + if (analysisPlatform == Platform.jvm) { + addClasspath(PathUtil.getJdkClassesRootsFromCurrentJre()) + } + for (element in pass.classpath) { + addClasspath(File(element)) + } + + addSources(pass.sourceRoots.map { it.path }) + + loadLanguageVersionSettings(pass.languageVersion, pass.apiVersion) + + val environment = createCoreEnvironment() + val (facade, _) = createResolutionFacade(environment) + + environment.getSourceFiles().asSequence() + .map { it.packageFqName } + .distinct() + .mapNotNull { facade.resolveSession.getPackageFragment(it) } + .map { DokkaDescriptorVisitor.visitPackageFragmentDescriptor(it, DRI.topLevel) } + .toList() + .let { Module(it) } + }.also { println("${pass.analysisPlatform}:\n${it.pretty()}\n\n") } } + } + +private class DokkaMessageCollector(private val logger: DokkaLogger) : MessageCollector { + override fun clear() { + seenErrors = false + } + + private var seenErrors = false + + override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation?) { + if (severity == CompilerMessageSeverity.ERROR) { + seenErrors = true + } + logger.error(MessageRenderer.PLAIN_FULL_PATHS.render(severity, message, location)) + } + + override fun hasErrors() = seenErrors +}
\ No newline at end of file |