From 6225a6dbb4b673b4a4fbda8b8405f5f6d7b4c79a Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Thu, 31 Oct 2019 16:27:28 +0100 Subject: Pseudo generator --- core/build.gradle | 2 +- core/src/main/kotlin/DokkaBootstrapImpl.kt | 76 ++++++++++++++++++++++++++++++ core/src/main/kotlin/DokkaGenerator.kt | 13 +++++ settings.gradle | 12 ++--- 4 files changed, 96 insertions(+), 7 deletions(-) create mode 100644 core/src/main/kotlin/DokkaBootstrapImpl.kt create mode 100644 core/src/main/kotlin/DokkaGenerator.kt diff --git a/core/build.gradle b/core/build.gradle index ea1ab325..20ff8760 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -21,7 +21,7 @@ allprojects { } dependencies { -// compile project(":integration") + compile project(":integration") compile project(path: ":coreDependencies", configuration: "shadow") compile "org.jetbrains.kotlin:kotlin-stdlib:$bundled_kotlin_compiler_version" diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt new file mode 100644 index 00000000..b48b62d4 --- /dev/null +++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt @@ -0,0 +1,76 @@ +package org.jetbrains.dokka + +import com.google.gson.Gson +import org.jetbrains.dokka.DokkaConfiguration.PackageOptions + +import java.util.function.BiConsumer + + +fun parsePerPackageOptions(arg: String): List { + if (arg.isBlank()) return emptyList() + + return arg.split(";").map { it.split(",") }.map { + val prefix = it.first() + if (prefix == "") + throw IllegalArgumentException("Please do not register packageOptions with all match pattern, use global settings instead") + val args = it.subList(1, it.size) + val deprecated = args.find { it.endsWith("deprecated") }?.startsWith("+") ?: true + val reportUndocumented = args.find { it.endsWith("warnUndocumented") }?.startsWith("+") ?: true + val privateApi = args.find { it.endsWith("privateApi") }?.startsWith("+") ?: false + val suppress = args.find { it.endsWith("suppress") }?.startsWith("+") ?: false + PackageOptionsImpl(prefix, includeNonPublic = privateApi, reportUndocumented = reportUndocumented, skipDeprecated = !deprecated, suppress = suppress) + } +} + +class DokkaBootstrapImpl : DokkaBootstrap { + + private class DokkaProxyLogger(val consumer: BiConsumer) : DokkaLogger { + override fun info(message: String) { + consumer.accept("info", message) + } + + override fun warn(message: String) { + consumer.accept("warn", message) + } + + override fun error(message: String) { + consumer.accept("error", message) + } + } + + lateinit var generator: DokkaGenerator + val gson = Gson() + + fun configure(logger: DokkaLogger, configuration: DokkaConfigurationImpl) = with(configuration) { + + fun defaultLinks(config: PassConfigurationImpl): List { + val links = mutableListOf() + if (!config.noJdkLink) + links += DokkaConfiguration.ExternalDocumentationLink + .Builder("https://docs.oracle.com/javase/${config.jdkVersion}/docs/api/") + .build() as ExternalDocumentationLinkImpl + + if (!config.noStdlibLink) + links += DokkaConfiguration.ExternalDocumentationLink + .Builder("https://kotlinlang.org/api/latest/jvm/stdlib/") + .build() as ExternalDocumentationLinkImpl + return links + } + + val configurationWithLinks = + configuration.copy(passesConfigurations = + passesConfigurations + .map { + val links: List = it.externalDocumentationLinks + defaultLinks(it) + it.copy(externalDocumentationLinks = links) + } + ) + + generator = DokkaGenerator(configurationWithLinks, logger) + } + + override fun configure(logger: BiConsumer, serializedConfigurationJSON: String) + = configure(DokkaProxyLogger(logger), gson.fromJson(serializedConfigurationJSON, DokkaConfigurationImpl::class.java)) + + override fun generate() = generator.generate() +} diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt new file mode 100644 index 00000000..abb6f069 --- /dev/null +++ b/core/src/main/kotlin/DokkaGenerator.kt @@ -0,0 +1,13 @@ +package org.jetbrains.dokka + +class DokkaGenerator( + private val configurationWithLinks: DokkaConfiguration, + private val logger: DokkaLogger +) { + fun generate() { + println("RUNNED") + logger.error("runned") + throw AssertionError() + } + +} diff --git a/settings.gradle b/settings.gradle index ff416c98..c793bd79 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,12 +2,12 @@ rootProject.name = "dokka" include 'core', // 'core:testApi', - 'coreDependencies'//, -// 'integration', + 'coreDependencies', + 'integration', // 'integration-tests:gradle-integration-tests', -// 'runners:fatjar', -// 'runners:ant', -// 'runners:cli', + 'runners:fatjar', + 'runners:ant', + 'runners:cli', // 'runners:maven-plugin', -// 'runners:gradle-plugin', + 'runners:gradle-plugin' // 'plugins:javadoc8' -- cgit