aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2023-11-10 11:46:54 +0100
committerGitHub <noreply@github.com>2023-11-10 11:46:54 +0100
commit8e5c63d035ef44a269b8c43430f43f5c8eebfb63 (patch)
tree1b915207b2b9f61951ddbf0ff2e687efd053d555 /core/src/main/kotlin
parenta44efd4ba0c2e4ab921ff75e0f53fc9335aa79db (diff)
downloaddokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.gz
dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.bz2
dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.zip
Restructure the project to utilize included builds (#3174)
* Refactor and simplify artifact publishing * Update Gradle to 8.4 * Refactor and simplify convention plugins and build scripts Fixes #3132 --------- Co-authored-by: Adam <897017+aSemy@users.noreply.github.com> Co-authored-by: Oleg Yukhnevich <whyoleg@gmail.com>
Diffstat (limited to 'core/src/main/kotlin')
-rw-r--r--core/src/main/kotlin/ConfigurationJsonUtils.kt54
-rw-r--r--core/src/main/kotlin/CoreExtensions.kt43
-rw-r--r--core/src/main/kotlin/DokkaBootstrap.kt15
-rw-r--r--core/src/main/kotlin/DokkaBootstrapImpl.kt69
-rw-r--r--core/src/main/kotlin/DokkaException.kt7
-rw-r--r--core/src/main/kotlin/DokkaGenerator.kt89
-rw-r--r--core/src/main/kotlin/DokkaVersion.kt15
-rw-r--r--core/src/main/kotlin/InternalDokkaApi.kt28
-rw-r--r--core/src/main/kotlin/configuration.kt280
-rw-r--r--core/src/main/kotlin/defaultConfiguration.kt100
-rw-r--r--core/src/main/kotlin/defaultExternalLinks.kt33
-rw-r--r--core/src/main/kotlin/generation/Generation.kt19
-rw-r--r--core/src/main/kotlin/links/DRI.kt146
-rw-r--r--core/src/main/kotlin/model/CompositeSourceSetID.kt46
-rw-r--r--core/src/main/kotlin/model/DisplaySourceSet.kt61
-rw-r--r--core/src/main/kotlin/model/Documentable.kt540
-rw-r--r--core/src/main/kotlin/model/JvmField.kt14
-rw-r--r--core/src/main/kotlin/model/WithChildren.kt98
-rw-r--r--core/src/main/kotlin/model/additionalExtras.kt142
-rw-r--r--core/src/main/kotlin/model/ancestryNode.kt18
-rw-r--r--core/src/main/kotlin/model/classKinds.kt24
-rw-r--r--core/src/main/kotlin/model/defaultValues.kt34
-rw-r--r--core/src/main/kotlin/model/doc/DocTag.kt372
-rw-r--r--core/src/main/kotlin/model/doc/DocumentationNode.kt9
-rw-r--r--core/src/main/kotlin/model/doc/TagWrapper.kt36
-rw-r--r--core/src/main/kotlin/model/documentableProperties.kt71
-rw-r--r--core/src/main/kotlin/model/documentableUtils.kt27
-rw-r--r--core/src/main/kotlin/model/extraModifiers.kt68
-rw-r--r--core/src/main/kotlin/model/jvmName.kt11
-rw-r--r--core/src/main/kotlin/model/properties/PropertyContainer.kt69
-rw-r--r--core/src/main/kotlin/model/properties/properties.kt36
-rw-r--r--core/src/main/kotlin/pages/ContentNodes.kt436
-rw-r--r--core/src/main/kotlin/pages/PageNodes.kt200
-rw-r--r--core/src/main/kotlin/pages/Pages.kt15
-rw-r--r--core/src/main/kotlin/pages/RendererSpecificPage.kt52
-rw-r--r--core/src/main/kotlin/pages/contentNodeProperties.kt37
-rw-r--r--core/src/main/kotlin/pages/utils.kt63
-rw-r--r--core/src/main/kotlin/plugability/DokkaContext.kt235
-rw-r--r--core/src/main/kotlin/plugability/DokkaJavaPlugin.kt78
-rw-r--r--core/src/main/kotlin/plugability/DokkaPlugin.kt114
-rw-r--r--core/src/main/kotlin/plugability/LazyEvaluated.kt21
-rw-r--r--core/src/main/kotlin/plugability/extensions.kt110
-rw-r--r--core/src/main/kotlin/renderers/PostAction.kt7
-rw-r--r--core/src/main/kotlin/renderers/Renderer.kt11
-rw-r--r--core/src/main/kotlin/transformers/documentation/DefaultDocumentableMerger.kt307
-rw-r--r--core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt12
-rw-r--r--core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt13
-rw-r--r--core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt12
-rw-r--r--core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt39
-rw-r--r--core/src/main/kotlin/transformers/pages/PageCreator.kt15
-rw-r--r--core/src/main/kotlin/transformers/pages/PageTransformer.kt11
-rw-r--r--core/src/main/kotlin/transformers/pages/PageTransformerBuilders.kt27
-rw-r--r--core/src/main/kotlin/transformers/sources/AsyncSourceToDocumentableTranslator.kt20
-rw-r--r--core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt13
-rw-r--r--core/src/main/kotlin/utilities/Collections.kt29
-rw-r--r--core/src/main/kotlin/utilities/DokkaLogging.kt90
-rw-r--r--core/src/main/kotlin/utilities/Html.kt23
-rw-r--r--core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt27
-rw-r--r--core/src/main/kotlin/utilities/ServiceLocator.kt99
-rw-r--r--core/src/main/kotlin/utilities/Uri.kt46
-rw-r--r--core/src/main/kotlin/utilities/associateWithNotNull.kt13
-rw-r--r--core/src/main/kotlin/utilities/cast.kt12
-rw-r--r--core/src/main/kotlin/utilities/json.kt65
-rw-r--r--core/src/main/kotlin/utilities/parallelCollectionOperations.kt26
-rw-r--r--core/src/main/kotlin/validity/PreGenerationChecker.kt17
65 files changed, 0 insertions, 4869 deletions
diff --git a/core/src/main/kotlin/ConfigurationJsonUtils.kt b/core/src/main/kotlin/ConfigurationJsonUtils.kt
deleted file mode 100644
index e693f4ef..00000000
--- a/core/src/main/kotlin/ConfigurationJsonUtils.kt
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.dokka
-
-import org.jetbrains.dokka.plugability.ConfigurableBlock
-import org.jetbrains.dokka.utilities.parseJson
-import org.jetbrains.dokka.utilities.serializeAsCompactJson
-import org.jetbrains.dokka.utilities.serializeAsPrettyJson
-
-public fun DokkaConfigurationImpl(json: String): DokkaConfigurationImpl = parseJson(json)
-
-public fun GlobalDokkaConfiguration(json: String): GlobalDokkaConfiguration = parseJson(json)
-
-@Deprecated("Renamed to better distinguish between compact/pretty prints", ReplaceWith("this.toCompactJsonString()"))
-public fun DokkaConfiguration.toJsonString(): String = this.toCompactJsonString()
-
-@Deprecated("Renamed to better distinguish between compact/pretty prints", ReplaceWith("this.toCompactJsonString()"))
-public fun <T : ConfigurableBlock> T.toJsonString(): String = this.toCompactJsonString()
-
-/**
- * Serializes [DokkaConfiguration] as a machine-readable and compact JSON string.
- *
- * The returned string is not very human friendly as it will be difficult to parse by eyes due to it
- * being compact and in one line. If you want to show the output to a human being, see [toPrettyJsonString].
- */
-public fun DokkaConfiguration.toCompactJsonString(): String = serializeAsCompactJson(this)
-
-/**
- * Serializes [DokkaConfiguration] as a human-readable (pretty printed) JSON string.
- *
- * The returned string will have excessive line breaks and indents, which might not be
- * desirable when passing this value between API consumers/producers. If you want
- * a machine-readable and compact json string, see [toCompactJsonString].
- */
-public fun DokkaConfiguration.toPrettyJsonString(): String = serializeAsPrettyJson(this)
-
-/**
- * Serializes a [ConfigurableBlock] as a machine-readable and compact JSON string.
- *
- * The returned string is not very human friendly as it will be difficult to parse by eyes due to it
- * being compact and in one line. If you want to show the output to a human being, see [toPrettyJsonString].
- */
-public fun <T : ConfigurableBlock> T.toCompactJsonString(): String = serializeAsCompactJson(this)
-
-/**
- * Serializes a [ConfigurableBlock] as a human-readable (pretty printed) JSON string.
- *
- * The returned string will have excessive line breaks and indents, which might not be
- * desirable when passing this value between API consumers/producers. If you want
- * a machine-readable and compact json string, see [toCompactJsonString].
- */
-public fun <T : ConfigurableBlock> T.toPrettyJsonString(): String = serializeAsCompactJson(this)
diff --git a/core/src/main/kotlin/CoreExtensions.kt b/core/src/main/kotlin/CoreExtensions.kt
deleted file mode 100644
index ca2504e2..00000000
--- a/core/src/main/kotlin/CoreExtensions.kt
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.dokka
-
-import org.jetbrains.dokka.generation.Generation
-import org.jetbrains.dokka.plugability.ExtensionPoint
-import org.jetbrains.dokka.renderers.PostAction
-import org.jetbrains.dokka.renderers.Renderer
-import org.jetbrains.dokka.transformers.documentation.DocumentableMerger
-import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator
-import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer
-import org.jetbrains.dokka.transformers.pages.PageTransformer
-import org.jetbrains.dokka.transformers.sources.SourceToDocumentableTranslator
-import org.jetbrains.dokka.validity.PreGenerationChecker
-import kotlin.reflect.KProperty
-
-public object CoreExtensions {
-
- public val preGenerationCheck: ExtensionPoint<PreGenerationChecker> by coreExtensionPoint<PreGenerationChecker>()
-
- public val generation: ExtensionPoint<Generation> by coreExtensionPoint<Generation>()
-
- public val sourceToDocumentableTranslator: ExtensionPoint<SourceToDocumentableTranslator> by coreExtensionPoint<SourceToDocumentableTranslator>()
-
- public val documentableMerger: ExtensionPoint<DocumentableMerger> by coreExtensionPoint<DocumentableMerger>()
-
- public val documentableTransformer: ExtensionPoint<DocumentableTransformer> by coreExtensionPoint<DocumentableTransformer>()
-
- public val documentableToPageTranslator: ExtensionPoint<DocumentableToPageTranslator> by coreExtensionPoint<DocumentableToPageTranslator>()
-
- public val pageTransformer: ExtensionPoint<PageTransformer> by coreExtensionPoint<PageTransformer>()
-
- public val renderer: ExtensionPoint<Renderer> by coreExtensionPoint<Renderer>()
-
- public val postActions: ExtensionPoint<PostAction> by coreExtensionPoint<PostAction>()
-
- private fun <T : Any> coreExtensionPoint() = object {
- operator fun provideDelegate(thisRef: CoreExtensions, property: KProperty<*>): Lazy<ExtensionPoint<T>> =
- lazy { ExtensionPoint(thisRef::class.qualifiedName!!, property.name) }
- }
-}
diff --git a/core/src/main/kotlin/DokkaBootstrap.kt b/core/src/main/kotlin/DokkaBootstrap.kt
deleted file mode 100644
index d3d82e39..00000000
--- a/core/src/main/kotlin/DokkaBootstrap.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.dokka
-
-import java.util.function.BiConsumer
-
-public interface DokkaBootstrap {
- @Throws(Throwable::class)
- public fun configure(serializedConfigurationJSON: String, logger: BiConsumer<String, String>)
-
- @Throws(Throwable::class)
- public fun generate()
-}
diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt
deleted file mode 100644
index 65f0ef72..00000000
--- a/core/src/main/kotlin/DokkaBootstrapImpl.kt
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.dokka
-
-import org.jetbrains.dokka.utilities.DokkaLogger
-import java.util.concurrent.atomic.AtomicInteger
-
-import java.util.function.BiConsumer
-
-/**
- * Accessed with reflection
- */
-@Suppress("unused")
-public class DokkaBootstrapImpl : DokkaBootstrap {
-
- public class DokkaProxyLogger(
- public val consumer: BiConsumer<String, String>
- ) : DokkaLogger {
- private val warningsCounter = AtomicInteger()
- private val errorsCounter = AtomicInteger()
-
- override var warningsCount: Int
- get() = warningsCounter.get()
- set(value) = warningsCounter.set(value)
-
- override var errorsCount: Int
- get() = errorsCounter.get()
- set(value) = errorsCounter.set(value)
-
- override fun debug(message: String) {
- consumer.accept("debug", message)
- }
-
- override fun info(message: String) {
- consumer.accept("info", message)
- }
-
- override fun progress(message: String) {
- consumer.accept("progress", message)
- }
-
- override fun warn(message: String) {
- consumer.accept("warn", message).also { warningsCounter.incrementAndGet() }
- }
-
- override fun error(message: String) {
- consumer.accept("error", message).also { errorsCounter.incrementAndGet() }
- }
- }
-
- private lateinit var generator: DokkaGenerator
-
- public fun configure(logger: DokkaLogger, configuration: DokkaConfigurationImpl) {
- generator = DokkaGenerator(configuration, logger)
- }
-
- override fun configure(serializedConfigurationJSON: String, logger: BiConsumer<String, String>) {
- configure(
- DokkaProxyLogger(logger),
- DokkaConfigurationImpl(serializedConfigurationJSON)
- )
- }
-
- override fun generate() {
- generator.generate()
- }
-}
diff --git a/core/src/main/kotlin/DokkaException.kt b/core/src/main/kotlin/DokkaException.kt
deleted file mode 100644
index f16a2649..00000000
--- a/core/src/main/kotlin/DokkaException.kt
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.dokka
-
-public open class DokkaException(message: String) : RuntimeException(message)
diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt
deleted file mode 100644
index 9ae3adb4..00000000
--- a/core/src/main/kotlin/DokkaGenerator.kt
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-@file:Suppress("SameParameterValue")
-
-package org.jetbrains.dokka
-
-import kotlinx.coroutines.DelicateCoroutinesApi
-import kotlinx.coroutines.Dispatchers
-import org.jetbrains.dokka.generation.GracefulGenerationExit
-import org.jetbrains.dokka.plugability.DokkaContext
-import org.jetbrains.dokka.plugability.DokkaPlugin
-import org.jetbrains.dokka.utilities.DokkaLogger
-
-/**
- * DokkaGenerator is the main entry point for generating documentation
- *
- * [generate] method has been split into submethods for test reasons
- */
-public class DokkaGenerator(
- private val configuration: DokkaConfiguration,
- private val logger: DokkaLogger
-) {
-
- public fun generate() {
- timed(logger) {
- report("Initializing plugins")
- val context = initializePlugins(configuration, logger)
-
- runCatching {
- context.single(CoreExtensions.generation).run {
- logger.progress("Dokka is performing: $generationName")
- generate()
- }
- }.exceptionOrNull()?.let { e ->
- finalizeCoroutines()
- throw e
- }
-
- finalizeCoroutines()
- }.dump("\n\n === TIME MEASUREMENT ===\n")
- }
-
- public fun initializePlugins(
- configuration: DokkaConfiguration,
- logger: DokkaLogger,
- additionalPlugins: List<DokkaPlugin> = emptyList()
- ): DokkaContext = DokkaContext.create(configuration, logger, additionalPlugins)
-
- @OptIn(DelicateCoroutinesApi::class)
- private fun finalizeCoroutines() {
- if (configuration.finalizeCoroutines) {
- Dispatchers.shutdown()
- }
- }
-}
-
-public class Timer internal constructor(startTime: Long, private val logger: DokkaLogger?) {
- private val steps = mutableListOf("" to startTime)
-
- public fun report(name: String) {
- logger?.progress(name)
- steps += (name to System.currentTimeMillis())
- }
-
- public fun dump(prefix: String = "") {
- logger?.info(prefix)
- val namePad = steps.map { it.first.length }.maxOrNull() ?: 0
- val timePad = steps.windowed(2).map { (p1, p2) -> p2.second - p1.second }.maxOrNull()?.toString()?.length ?: 0
- steps.windowed(2).forEach { (p1, p2) ->
- if (p1.first.isNotBlank()) {
- logger?.info("${p1.first.padStart(namePad)}: ${(p2.second - p1.second).toString().padStart(timePad)}")
- }
- }
- }
-}
-
-private fun timed(logger: DokkaLogger? = null, block: Timer.() -> Unit): Timer =
- Timer(System.currentTimeMillis(), logger).apply {
- try {
- block()
- } catch (exit: GracefulGenerationExit) {
- report("Exiting Generation: ${exit.reason}")
- } finally {
- report("")
- }
- }
-
diff --git a/core/src/main/kotlin/DokkaVersion.kt b/core/src/main/kotlin/DokkaVersion.kt
deleted file mode 100644
index d846988b..00000000
--- a/core/src/main/kotlin/DokkaVersion.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.dokka
-
-import java.util.*
-
-public object DokkaVersion {
- public val version: String by lazy {
- javaClass.getResourceAsStream("/META-INF/dokka/dokka-version.properties").use { stream ->
- Properties().apply { load(stream) }.getProperty("dokka-version")
- }
- }
-}
diff --git a/core/src/main/kotlin/InternalDokkaApi.kt b/core/src/main/kotlin/InternalDokkaApi.kt
deleted file mode 100644
index 65c0427c..00000000
--- a/core/src/main/kotlin/InternalDokkaApi.kt
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.dokka
-
-
-/**
- * Marks declarations that are **internal** to Dokka core artifact.
- * It means that this API is marked as **public** either for historical or technical reasons.
- * It is not intended to be used outside of the Dokka project, has no behaviour guarantees,
- * and may lack clear semantics, documentation and backward compatibility.
- *
- * If you are using such API, it is strongly suggested to migrate from it in order
- * to keep backwards compatibility with future Dokka versions.
- * Typically, the easiest way to do so is to copy-paste the corresponding utility into
- * your own project.
- */
-@RequiresOptIn(
- level = RequiresOptIn.Level.ERROR,
- message = "This is an internal Dokka API not intended for public use"
-)
-@Target(
- AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.FIELD,
- AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS
-)
-@Retention(AnnotationRetention.BINARY)
-public annotation class InternalDokkaApi()
diff --git a/core/src/main/kotlin/configuration.kt b/core/src/main/kotlin/configuration.kt
deleted file mode 100644
index 65035d04..00000000
--- a/core/src/main/kotlin/configuration.kt
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.dokka
-
-import org.jetbrains.dokka.utilities.cast
-import java.io.File
-import java.io.Serializable
-import java.net.URL
-
-public object DokkaDefaults {
- public val moduleName: String = "root"
- public val moduleVersion: String? = null
- public val outputDir: File = File("./dokka")
- public const val failOnWarning: Boolean = false
- public const val suppressObviousFunctions: Boolean = true
- public const val suppressInheritedMembers: Boolean = false
- public const val offlineMode: Boolean = false
-
- public const val sourceSetDisplayName: String = "JVM"
- public const val sourceSetName: String = "main"
- public val analysisPlatform: Platform = Platform.DEFAULT
-
- public const val suppress: Boolean = false
- public const val suppressGeneratedFiles: Boolean = true
-
- public const val skipEmptyPackages: Boolean = true
- public const val skipDeprecated: Boolean = false
-
- public const val reportUndocumented: Boolean = false
-
- public const val noStdlibLink: Boolean = false
- public const val noAndroidSdkLink: Boolean = false
- public const val noJdkLink: Boolean = false
- public const val jdkVersion: Int = 8
-
- public const val includeNonPublic: Boolean = false
- public val documentedVisibilities: Set<DokkaConfiguration.Visibility> = setOf(DokkaConfiguration.Visibility.PUBLIC)
-
- public val pluginsConfiguration: List<PluginConfigurationImpl> = mutableListOf()
-
- public const val delayTemplateSubstitution: Boolean = false
-
- public val cacheRoot: File? = null
-}
-
-public enum class Platform(
- public val key: String
-) {
- jvm("jvm"),
- js("js"),
- wasm("wasm"),
- native("native"),
- common("common");
-
- public companion object {
- public val DEFAULT: Platform = jvm
-
- public fun fromString(key: String): Platform {
- return when (key.toLowerCase()) {
- jvm.key -> jvm
- js.key -> js
- wasm.key -> wasm
- native.key -> native
- common.key -> common
- "androidjvm", "android" -> jvm
- "metadata" -> common
- else -> throw IllegalArgumentException("Unrecognized platform: $key")
- }
- }
- }
-}
-
-public fun interface DokkaConfigurationBuilder<T : Any> {
- public fun build(): T
-}
-
-public fun <T : Any> Iterable<DokkaConfigurationBuilder<T>>.build(): List<T> = this.map { it.build() }
-
-public data class DokkaSourceSetID(
- /**
- * Unique identifier of the scope that this source set is placed in.
- * Each scope provide only unique source set names.
- *
- * E.g. One DokkaTask inside the Gradle plugin represents one source set scope, since there cannot be multiple
- * source sets with the same name. However, a Gradle project will not be a proper scope, since there can be
- * multple DokkaTasks that contain source sets with the same name (but different configuration)
- */