diff --git a/docs/dokka.tree b/docs/dokka.tree
index 49a8b4bbce..76ec6f967f 100644
--- a/docs/dokka.tree
+++ b/docs/dokka.tree
@@ -1,11 +1,12 @@
-
+
+
diff --git a/docs/labels.list b/docs/labels.list
new file mode 100644
index 0000000000..b8cd77c802
--- /dev/null
+++ b/docs/labels.list
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+ The feature is Experimental. It may be dropped or changed at any time. Use it only for evaluation purposes.
+ The feature is Experimental. It may be dropped or changed at any time. Opt-in is required (see the details below), and you should use it only for evaluation purposes.
+ The feature is in Alpha. It may change incompatibly and require manual migration in the future.
+ The feature is in Beta. It is almost stable, but migration steps may be required in the future. We'll do our best to minimize any changes you have to make.
+
+ This functionality is available only in the latest EAP version.
+
+ This functionality is available only in the latest EAP version.
+
\ No newline at end of file
diff --git a/docs/topics/dokka-get-started.md b/docs/topics/dokka-get-started.md
index e08eb2ba10..6edc9c29f4 100644
--- a/docs/topics/dokka-get-started.md
+++ b/docs/topics/dokka-get-started.md
@@ -5,18 +5,14 @@ Below you can find simple instructions to help you get started with Dokka.
-> These instructions reflect Dokka Gradle plugin v1 configuration and tasks. Starting from Dokka 2.0.0, several configuration options, Gradle tasks, and steps to generate your documentation have been updated, including:
->
-> * [Adjust configuration options](dokka-migration.md#adjust-configuration-options)
-> * [Work with multi-module projects](dokka-migration.md#share-dokka-configuration-across-modules)
-> * [Generate documentation with the updated tasks](dokka-migration.md#generate-documentation-with-the-updated-task)
-> * [Specify an output directory](dokka-migration.md#output-directory)
->
-> For more details and the full list of changes in Dokka Gradle Plugin v2, see the [Migration guide](dokka-migration.md).
+> This guide applies to Dokka Gradle Plugin (DGP) v2 mode. The previous DGP v1 mode is no longer supported.
+> If you're upgrading from v1 to v2 mode, see the [Migration guide](dokka-migration.md).
>
{style="note"}
-Apply the Gradle plugin for Dokka in the root build script of your project:
+**Apply the Gradle Dokka plugin**
+
+Apply the Dokka Gradle plugin (DGP) in the root build script of your project:
```kotlin
plugins {
@@ -24,21 +20,34 @@ plugins {
}
```
-When documenting [multi-project](https://docs.gradle.org/current/userguide/multi_project_builds.html) builds, you need
-to apply the Gradle plugin within subprojects as well:
+**Document multi-project builds**
-```kotlin
-subprojects {
- apply(plugin = "org.jetbrains.dokka")
-}
+When documenting [multi-project builds](https://docs.gradle.org/current/userguide/multi_project_builds.html),
+you need to apply the plugin to every subproject you want to document. Share Dokka configuration across subprojects
+by using one of the following approaches:
+
+* Convention plugin
+* Direct configuration in each subproject if you’re not using convention plugins
+
+For more information about sharing Dokka configuration in multi-project builds,
+see [Multi-project configuration](dokka-gradle.md#multi-project-configuration).
+
+**Generate documentation**
+
+To generate documentation, run the following Gradle task:
+
+```Bash
+./gradlew :dokkaGenerate
```
-To generate documentation, run the following Gradle tasks:
+This task works for both single and multi-project builds.
+You can use different tasks to generate output in [HTML](dokka-html.md),
+[Javadoc](dokka-javadoc.md) or both [HTML and Javadoc](dokka-gradle.md#configure-documentation-output-format).
-* `dokkaHtml` for single-project builds
-* `dokkaHtmlMultiModule` for multi-project builds
+**Set output directory**
-By default, the output directory is set to `/build/dokka/html` and `/build/dokka/htmlMultiModule`.
+By default, the output directory is set to `/build/dokka/html` for both multi-project and single-project builds,
+but you can [configure it](dokka-gradle.md#general-configuration).
To learn more about using Dokka with Gradle, see [Gradle](dokka-gradle.md).
@@ -69,7 +78,9 @@ To generate documentation, run the following Gradle tasks:
By default, the output directory is set to `/build/dokka/html` and `/build/dokka/htmlMultiModule`.
-To learn more about using Dokka with Gradle, see [Gradle](dokka-gradle.md).
+> To learn more about using Dokka with Gradle, see [Gradle](dokka-gradle.md).
+>
+{style="tip"}
diff --git a/docs/topics/dokka-gradle-troubleshooting-md.md b/docs/topics/dokka-gradle-troubleshooting-md.md
new file mode 100644
index 0000000000..64a9c489e9
--- /dev/null
+++ b/docs/topics/dokka-gradle-troubleshooting-md.md
@@ -0,0 +1,71 @@
+[//]: # (title: Dokka Gradle troubleshooting)
+
+In large projects, Dokka can consume a significant amount of memory to generate documentation.
+This can exceed Gradle’s memory limits, especially when processing large volumes of data.
+
+When Dokka generation runs out of memory, the build fails,
+and Gradle can throw exceptions like `java.lang.OutOfMemoryError: Metaspace`.
+
+Active efforts are underway to improve Dokka's performance, although some limitations stem from Gradle.
+
+If you encounter memory issues, try these workarounds:
+
+* [Increasing heap space](#increase-heap-space)
+* [Running Dokka within the Gradle process](#run-dokka-within-the-gradle-process)
+
+### Increase heap space
+
+One way to resolve memory issues is to increase the amount of Java heap memory for the Dokka generator process.
+In the `build.gradle.kts` file, adjust the
+following configuration option:
+
+```kotlin
+ dokka {
+ // Dokka generates a new process managed by Gradle
+ dokkaGeneratorIsolation = ProcessIsolation {
+ // Configures heap size
+ maxHeapSize = "4g"
+ }
+ }
+```
+
+In this example, the maximum heap size is set to 4 GB (`"4g"`).
+Adjust and test the value to find the optimal setting for your build.
+
+If you find that Dokka requires a considerably expanded heap size,
+for example, significantly higher than Gradle's own memory usage,
+[create an issue on Dokka's GitHub repository](https://kotl.in/dokka-issues).
+
+> You have to apply this configuration to each subproject.
+> It is recommended that you configure Dokka in a convention
+> plugin applied to all subprojects.
+>
+{style="note"}
+
+### Run Dokka within the Gradle process
+
+When both the Gradle build and Dokka generation require a lot of memory, they may run as separate processes,
+consuming significant memory on a single machine.
+
+To optimize memory usage, you can run Dokka within the same Gradle process instead of as a separate process.
+This allows you to configure the memory for Gradle once instead of allocating it separately for each process.
+
+To run Dokka within the same Gradle process, adjust the following configuration option in the `build.gradle.kts` file:
+
+```kotlin
+ dokka {
+ // Runs Dokka in the current Gradle process
+ dokkaGeneratorIsolation = ClassLoaderIsolation()
+ }
+```
+
+As with [increasing heap space](#increase-heap-space), test this configuration to confirm it works well for your project.
+
+For more details on configuring Gradle's JVM memory,
+see the [Gradle documentation](https://docs.gradle.org/current/userguide/config_gradle.html#sec:configuring_jvm_memory).
+
+> Changing the Java options for Gradle launches a new Gradle daemon, which may stay alive for a long time. You can [manually stop any other Gradle processes](https://docs.gradle.org/current/userguide/gradle_daemon.html#sec:stopping_an_existing_daemon).
+>
+> Additionally, Gradle issues with the `ClassLoaderIsolation()` configuration may [cause memory leaks](https://github.com/gradle/gradle/issues/18313).
+>
+{style="note"}
\ No newline at end of file
diff --git a/docs/topics/dokka-migration.md b/docs/topics/dokka-migration.md
index dd0f145cf0..1d23fdb3f1 100644
--- a/docs/topics/dokka-migration.md
+++ b/docs/topics/dokka-migration.md
@@ -5,10 +5,7 @@ The Dokka Gradle plugin (DGP) is a tool for generating comprehensive API documen
DGP seamlessly processes both Kotlin's KDoc comments and Java's Javadoc comments to extract information and create
structured documentation in [HTML or Javadoc](#select-documentation-output-format) format.
-Starting with Dokka 2.0.0, you can try the Dokka Gradle plugin v2, the new version of DGP. With Dokka 2.0.0, you can use
-the Dokka Gradle plugin either in v1 or v2 modes.
-
-DGP v2 introduces significant improvements to DGP, aligning more closely with Gradle best practices:
+The Dokka Gradle plugin v2 mode is enabled by default and aligns with Gradle best practices:
* Adopts Gradle types, which leads to better performance.
* Uses an intuitive top-level DSL configuration instead of a low-level task-based setup, which simplifies the build scripts and their readability.
@@ -17,6 +14,8 @@ DGP v2 introduces significant improvements to DGP, aligning more closely with Gr
* Fully supports Gradle [configuration cache](https://docs.gradle.org/current/userguide/configuration_cache.html) and
[build cache](https://docs.gradle.org/current/userguide/build_cache.html), which improves performance and simplifies build work.
+Read this guide for further information between changes and migration from DGP v1 to v2 modes.
+
## Before you start
Before starting the migration, complete the following steps.
@@ -44,7 +43,7 @@ Update the Dokka version to 2.0.0 in the `plugins {}` block of your project’s
```kotlin
plugins {
kotlin("jvm") version "2.1.10"
- id("org.jetbrains.dokka") version "2.0.0"
+ id("org.jetbrains.dokka") version "%dokkaVersion%"
}
```
@@ -526,15 +525,15 @@ For an example of the DGP v2 configuration, see the
DGP v2 allows you to extend its functionality by [configuring custom plugins](https://github.com/Kotlin/dokka/blob/ae3840edb4e4afd7b3e3768a5fddfe8ec0e08f31/examples/gradle-v2/custom-dokka-plugin-example/demo-library/build.gradle.kts).
Custom plugins enable additional processing or modifications to the documentation generation process.
-### Share Dokka configuration across modules
+### Share Dokka configuration across subprojects
-DPG v2 moves away from using `subprojects {}` or `allprojects {}` to share configuration across modules. In future Gradle versions,
+DPG v2 moves away from using `subprojects {}` or `allprojects {}` to share configuration across subprojects. In future Gradle versions,
using these approaches will [lead to errors](https://docs.gradle.org/current/userguide/isolated_projects.html).
Follow the steps below to properly share Dokka configuration in multi-module projects [with existing convention plugins](#multi-module-projects-with-convention-plugins)
or [without convention plugins](#multi-module-projects-without-convention-plugins).
-After sharing the Dokka configuration, you can aggregate the documentation from multiple modules into a single output. For more information, see
+After sharing the Dokka configuration, you can aggregate the documentation from multiple subprojects into a single output. For more information, see
[Update documentation aggregation in multi-module projects](#update-documentation-aggregation-in-multi-module-projects).
> For a multi-module project example, see the [Dokka GitHub repository](https://github.com/Kotlin/dokka/tree/master/examples/gradle-v2/multimodule-example).
@@ -543,12 +542,12 @@ After sharing the Dokka configuration, you can aggregate the documentation from
#### Multi-module projects without convention plugins
-If your project doesn't use convention plugins, you can still share Dokka configurations by directly configuring each module.
-This involves manually setting up the shared configuration in each module's `build.gradle.kts` file. While this approach is less centralized,
+If your project doesn't use convention plugins, you can still share Dokka configurations by directly configuring each subproject.
+This involves manually setting up the shared configuration in each subproject's `build.gradle.kts` file. While this approach is less centralized,
it avoids the need for additional setups like convention plugins.
Otherwise, if your project uses convention plugins, you can also share the Dokka configuration in multi-module projects
-by creating a convention plugin in the `buildSrc` directory, and then applying the plugin to your modules (subprojects).
+by creating a convention plugin in the `buildSrc` directory, and then applying the plugin to your subprojects.
##### Set up the buildSrc directory
@@ -600,9 +599,9 @@ After setting up the `buildSrc` directory:
You need to add the shared Dokka [configuration](#adjust-configuration-options) common to all subprojects within the `dokka {}` block.
Also, you don't need to specify a Dokka version. The version is already set in the `buildSrc/build.gradle.kts` file.
-##### Apply the convention plugin to your modules
+##### Apply the convention plugin to your subprojects
-Apply the Dokka convention plugin across your modules (subprojects) by adding it to each subproject's `build.gradle.kts` file:
+Apply the Dokka convention plugin across your subprojects by adding it to each subproject's `build.gradle.kts` file:
```kotlin
plugins {
@@ -615,13 +614,13 @@ plugins {
If you already have convention plugins, create a dedicated Dokka convention plugin following [Gradle's documentation](https://docs.gradle.org/current/userguide/custom_plugins.html#sec:convention_plugins).
Then, follow the steps to [set up the Dokka convention plugin](#set-up-the-dokka-convention-plugin) and
-[apply it across your modules](#apply-the-convention-plugin-to-your-modules).
+[apply it across your subprojects](#apply-the-convention-plugin-to-your-subprojects).
### Update documentation aggregation in multi-module projects
-Dokka can aggregate the documentation from multiple modules (subprojects) into a single output or publication.
+Dokka can aggregate the documentation from multiple subprojects into a single output or publication.
-As [explained](#apply-the-convention-plugin-to-your-modules), apply the Dokka plugin to all documentable subprojects before aggregating the documentation.
+As [explained](#apply-the-convention-plugin-to-your-subprojects), apply the Dokka plugin to all documentable subprojects before aggregating the documentation.
Aggregation in DGP v2 uses the `dependencies {}` block instead of tasks and can be added in any `build.gradle.kts` file.
@@ -647,7 +646,7 @@ dependencies {
### Change directory of aggregated documentation
-When DGP aggregates modules, each subproject has its own subdirectory within the aggregated documentation.
+When DGP aggregates subprojects, each subproject has its own subdirectory within the aggregated documentation.
In DGP v2, the aggregation mechanism has been updated to better align with Gradle conventions.
DGP v2 now preserves the full subproject directory to prevent conflicts when aggregating
@@ -677,7 +676,7 @@ may become outdated, potentially causing `404` errors.
#### Revert to the DGP v1 directory behavior
-If your project depends on the directory structure used in DGP v1, you can revert this behavior by manually specifying the module directory.
+If your project depends on the directory structure used in DGP v1, you can revert this behavior by manually specifying the subproject directory.
Add the following configuration to the `build.gradle.kts` file of each subproject:
```kotlin
@@ -688,7 +687,7 @@ plugins {
}
dokka {
- // Overrides the module directory to match the V1 structure
+ // Overrides the subproject directory to match the V1 structure
modulePath.set("maths")
}
```
@@ -734,10 +733,10 @@ or both formats at the same time:
```kotlin
plugins {
// Generates HTML documentation
- id("org.jetbrains.dokka") version "2.0.0"
+ id("org.jetbrains.dokka") version "%dokkaVersion%"
// Generates Javadoc documentation
- id("org.jetbrains.dokka-javadoc") version "2.0.0"
+ id("org.jetbrains.dokka-javadoc") version "%dokkaVersion%"
// Keeping both plugin IDs generates both formats
}
@@ -786,73 +785,6 @@ DGP v2 now supports Gradle build cache and configuration cache, improving build
* To enable build cache, follow instructions in the [Gradle build cache documentation](https://docs.gradle.org/current/userguide/build_cache.html#sec:build_cache_enable).
* To enable configuration cache, follow instructions in the [Gradle configuration cache documentation](https://docs.gradle.org/current/userguide/configuration_cache.html#config_cache:usage:enable ).
-## Troubleshooting
-
-In large projects, Dokka can consume a significant amount of memory to generate documentation.
-This can exceed Gradle’s memory limits, especially when processing large volumes of data.
-
-When Dokka generation runs out of memory, the build fails, and Gradle can throw exceptions like `java.lang.OutOfMemoryError: Metaspace`.
-
-Active efforts are underway to improve Dokka's performance, although some limitations stem from Gradle.
-
-If you encounter memory issues, try these workarounds:
-
-* [Increasing heap space](#increase-heap-space)
-* [Running Dokka within the Gradle process](#run-dokka-within-the-gradle-process)
-
-### Increase heap space
-
-One way to resolve memory issues is to increase the amount of Java heap memory for the Dokka generator process.
-In the `build.gradle.kts` file, adjust the
-following configuration option:
-
-```kotlin
- dokka {
- // Dokka generates a new process managed by Gradle
- dokkaGeneratorIsolation = ProcessIsolation {
- // Configures heap size
- maxHeapSize = "4g"
- }
- }
-```
-
-In this example, the maximum heap size is set to 4 GB (`"4g"`). Adjust and test the value to find the optimal setting for your build.
-
-If you find that Dokka requires a considerably expanded heap size, for example, significantly higher than Gradle's own memory usage,
-[create an issue on Dokka's GitHub repository](https://kotl.in/dokka-issues).
-
-> You have to apply this configuration to each subproject. It is recommended that you configure Dokka in a convention
-> plugin applied to all subprojects.
->
-{style="note"}
-
-### Run Dokka within the Gradle process
-
-When both the Gradle build and Dokka generation require a lot of memory, they may run as separate processes,
-consuming significant memory on a single machine.
-
-To optimize memory usage, you can run Dokka within the same Gradle process instead of as a separate process. This
-allows you to configure the memory for Gradle once instead of allocating it separately for each process.
-
-To run Dokka within the same Gradle process, adjust the following configuration option in the `build.gradle.kts` file:
-
-```kotlin
- dokka {
- // Runs Dokka in the current Gradle process
- dokkaGeneratorIsolation = ClassLoaderIsolation()
- }
-```
-
-As with [increasing heap space](#increase-heap-space), test this configuration to confirm it works well for your project.
-
-For more details on configuring Gradle's JVM memory, see the [Gradle documentation](https://docs.gradle.org/current/userguide/config_gradle.html#sec:configuring_jvm_memory).
-
-> Changing the Java options for Gradle launches a new Gradle daemon, which may stay alive for a long time. You can [manually stop any other Gradle processes](https://docs.gradle.org/current/userguide/gradle_daemon.html#sec:stopping_an_existing_daemon).
->
-> Additionally, Gradle issues with the `ClassLoaderIsolation()` configuration may [cause memory leaks](https://github.com/gradle/gradle/issues/18313).
->
-{style="note"}
-
## What's next
* [Explore more DGP v2 project examples](https://github.com/Kotlin/dokka/tree/master/examples/gradle-v2).
diff --git a/docs/topics/dokka-module-and-package-docs.md b/docs/topics/dokka-module-and-package-docs.md
index d6c7af0baa..fdb6de0b0f 100644
--- a/docs/topics/dokka-module-and-package-docs.md
+++ b/docs/topics/dokka-module-and-package-docs.md
@@ -1,15 +1,15 @@
-[//]: # (title: Module documentation)
+[//]: # (title: Subproject documentation)
-Documentation for a module as a whole, as well as packages in that module, can be provided as separate Markdown files.
+Documentation for a subproject as a whole, as well as packages in that subproject, can be provided as separate Markdown files.
## File format
-Inside the Markdown file, the documentation for the module as a whole and for individual packages is introduced by the corresponding
-first-level headings. The text of the heading **must** be **Module ``** for a module, and **Package ``**
+Inside the Markdown file, the documentation for the subproject as a whole and for individual packages is introduced by the corresponding
+first-level headings. The text of the heading **must** be **Module ``** for a subproject, and **Package ``**
for a package.
-The file doesn't have to contain both module and package documentation. You can have files that contain only package or
-module documentation. You can even have a Markdown file per module or package.
+The file doesn't have to contain both subproject and package documentation. You can have files that contain only package or
+subproject documentation. You can even have a Markdown file per subproject or package.
Using [Markdown syntax](https://www.markdownguide.org/basic-syntax/), you can add:
* Headings up to level 6
@@ -19,12 +19,12 @@ Using [Markdown syntax](https://www.markdownguide.org/basic-syntax/), you can ad
* Code blocks
* Blockquotes
-Here's an example file containing both module and package documentation:
+Here's an example file containing both subproject and package documentation:
```text
# Module kotlin-demo
-This content appears under your module name.
+This content appears under your subproject name.
# Package org.jetbrains.kotlin.demo
diff --git a/docs/topics/dokka-plugins.md b/docs/topics/dokka-plugins.md
index 8fe048d7c5..17dd15cdf0 100644
--- a/docs/topics/dokka-plugins.md
+++ b/docs/topics/dokka-plugins.md
@@ -1,5 +1,10 @@
[//]: # (title: Dokka plugins)
+> This guide applies to Dokka Gradle Plugin (DGP) v2 mode. The previous DGP v1 mode is no longer supported.
+> If you're upgrading from v1 to v2 mode, see the [Migration guide](dokka-migration.md).
+>
+{style="note"}
+
Dokka was built from the ground up to be easily extensible and highly customizable, which allows the community
to implement plugins for missing or very specific features that are not provided out of the box.
@@ -13,11 +18,11 @@ If you want to learn how to create Dokka plugins, see
## Apply Dokka plugins
-Dokka plugins are published as separate artifacts, so to apply a Dokka plugin you only need to add it as a dependency.
-From there, the plugin extends Dokka by itself - no further action is needed.
+Dokka plugins are published as separate artifacts, so to apply a Dokka plugin, you only need to add it as a dependency.
+From there, the plugin extends Dokka by itself—no further action is needed.
> Plugins that use the same extension points or work in a similar way can interfere with each other.
-> This may lead to visual bugs, general undefined behaviour or even failed builds. However, it should not lead to
+> This may lead to visual bugs, general undefined behavior or even failed builds. However, it should not lead to
> concurrency issues since Dokka does not expose any mutable data structures or objects.
>
> If you notice problems like this, it's a good idea to check which plugins are applied and what they do.
@@ -30,34 +35,22 @@ to your project:
-> These instructions reflect Dokka Gradle plugin v1 configuration and tasks. Starting from Dokka 2.0.0, several configuration options, Gradle tasks, and steps to generate your documentation have been updated, including:
->
-> * [Configure Dokka plugins](dokka-migration.md#configure-dokka-plugins)
-> * [Work with multi-module projects](dokka-migration.md#share-dokka-configuration-across-modules)
->
-> For more details and the full list of changes in Dokka Gradle Plugin v2, see the [Migration guide](dokka-migration.md).
->
-> {style="note"}
-
-The Gradle plugin for Dokka creates convenient dependency configurations that allow you to apply plugins universally or
-for a specific output format only.
+The way to apply Dokka plugins is:
```kotlin
-dependencies {
- // Is applied universally
- dokkaPlugin("org.jetbrains.dokka:mathjax-plugin:%dokkaVersion%")
-
- // Is applied for the single-module dokkaHtml task only
- dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:%dokkaVersion%")
+plugins {
+ id("org.jetbrains.dokka") version "%dokkaVersion%"
+}
- // Is applied for HTML format in multi-project builds
- dokkaHtmlPartialPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:%dokkaVersion%")
+dependencies {
+ dokkaPlugin("org.jetbrains.dokka:mathjax-plugin")
}
```
-> When documenting [multi-project](dokka-gradle.md#multi-project-builds) builds, you need to apply Dokka plugins within
-> subprojects as well as in their parent project.
+> * Built-in plugins (like HTML and Javadoc) are always applied automatically. You only configure them and do not need dependencies for them.
>
+> * When documenting multi-module projects (multi-project builds), you need to [share Dokka configuration and plugins across subprojects](dokka-gradle.md#multi-project-configuration).
+>
{style="note"}
@@ -79,7 +72,8 @@ dependencies {
}
```
-> When documenting [multi-project](dokka-gradle.md#multi-project-builds) builds, you need to apply Dokka plugins within
+> When documenting [multi-project](dokka-gradle.md#multi-project-configuration) builds,
+> you need to apply Dokka plugins within
> subprojects as well as in their parent project.
>
{style="note"}
@@ -139,57 +133,32 @@ If you are using [JSON configuration](dokka-cli.md#run-with-json-configuration),
Dokka plugins can also have configuration options of their own. To see which options are available, consult
the documentation of the plugins you are using.
-Let's have a look at how you can configure the `DokkaBase` plugin, which is responsible for generating [HTML](dokka-html.md)
-documentation, by adding a custom image to the assets (`customAssets` option), by adding custom style sheets
-(`customStyleSheets` option), and by modifying the footer message (`footerMessage` option):
+Let's have a look at how you can configure the built-in HTML plugin by adding a custom image to the assets
+(`customAssets` option),
+custom style sheets (`customStyleSheets` option), and a modified footer message (`footerMessage` option):
-Gradle's Kotlin DSL allows for type-safe plugin configuration. This is achievable by adding the plugin's artifact to
-the classpath dependencies in the `buildscript` block, and then importing plugin and configuration classes:
+To configure Dokka plugins in a type-safe way, use the `dokka.pluginsConfiguration {}` block:
```kotlin
-import org.jetbrains.dokka.base.DokkaBase
-import org.jetbrains.dokka.gradle.DokkaTask
-import org.jetbrains.dokka.base.DokkaBaseConfiguration
-
-buildscript {
- dependencies {
- classpath("org.jetbrains.dokka:dokka-base:%dokkaVersion%")
- }
-}
-
-tasks.withType().configureEach {
- pluginConfiguration {
- customAssets = listOf(file("my-image.png"))
- customStyleSheets = listOf(file("my-styles.css"))
- footerMessage = "(c) 2022 MyOrg"
+dokka {
+ pluginsConfiguration.html {
+ customAssets.from("logo.png")
+ customStyleSheets.from("styles.css")
+ footerMessage.set("(c) Your Company")
}
}
```
-Alternatively, plugins can be configured via JSON. With this method, no additional dependencies are needed.
+For an example of Dokka plugins configuration, see the
+[Dokka's versioning plugin](https://github.com/Kotlin/dokka/tree/master/examples/gradle-v2/versioning-multimodule-example).
-```kotlin
-import org.jetbrains.dokka.gradle.DokkaTask
-
-tasks.withType().configureEach {
- val dokkaBaseConfiguration = """
- {
- "customAssets": ["${file("assets/my-image.png")}"],
- "customStyleSheets": ["${file("assets/my-styles.css")}"],
- "footerMessage": "(c) 2022 MyOrg"
- }
- """
- pluginsMapConfiguration.set(
- mapOf(
- // fully qualified plugin name to json configuration
- "org.jetbrains.dokka.base.DokkaBase" to dokkaBaseConfiguration
- )
- )
-}
-```
+Dokka allows you
+to extend its functionality
+by [configuring custom plugins](https://github.com/Kotlin/dokka/blob/v2.1.0/examples/gradle-v2/custom-dokka-plugin-example/demo-library/build.gradle.kts).
+Custom plugins enable additional processing or modifications to the documentation generation process.
@@ -281,7 +250,7 @@ Here are some notable Dokka plugins that you might find useful:
| [Versioning plugin](https://github.com/Kotlin/dokka/tree/%dokkaVersion%/dokka-subprojects/plugin-versioning) | Adds version selector and helps to organize documentation for different versions of your application/library |
| [MermaidJS HTML plugin](https://github.com/glureau/dokka-mermaid) | Renders [MermaidJS](https://mermaid-js.github.io/mermaid/#/) diagrams and visualizations found in KDocs |
| [Mathjax HTML plugin](https://github.com/Kotlin/dokka/tree/%dokkaVersion%/dokka-subprojects/plugin-mathjax) | Pretty prints mathematics found in KDocs |
-| [Kotlin as Java plugin](https://github.com/Kotlin/dokka/tree/%dokkaVersion%/dokka-subprojects/plugin-kotlin-as-java) | Renders Kotlin signatures as seen from Java's perspective |
+| [Kotlin as Java plugin](https://github.com/Kotlin/dokka/tree/%dokkaVersion%/dokka-subprojects/plugin-kotlin-as-java) | Renders Kotlin signatures as seen from Java's perspective |
If you are a Dokka plugin author and would like to add your plugin to this list, get in touch with maintainers
via [Slack](dokka-introduction.md#community) or [GitHub](https://github.com/Kotlin/dokka/).
diff --git a/docs/topics/formats/dokka-html.md b/docs/topics/formats/dokka-html.md
index f8e9b11b43..eb4079b153 100644
--- a/docs/topics/formats/dokka-html.md
+++ b/docs/topics/formats/dokka-html.md
@@ -1,23 +1,34 @@
[//]: # (title: HTML)
-HTML is Dokka's default and recommended output format. It is currently in Beta and approaching the Stable release.
+> This guide applies to Dokka Gradle Plugin (DGP) v2 mode. The previous DGP v1 mode is no longer supported.
+> If you're upgrading from v1 to v2 mode, see the [Migration guide](dokka-migration.md).
+>
+{style="note"}
+
+HTML is Dokka's default and recommended output format.
+It provides support for Kotlin Multiplatform, Android, and Java projects.
+Additionally, you can use the HTML format to document both single and multi-project builds.
-You can see an example of the output by browsing documentation
-for [kotlinx.coroutines](https://kotlinlang.org/api/kotlinx.coroutines/).
+For examples of the HTML output format, check the following docs:
+* [kotlinx.coroutines](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/)
+* [Bitmovin](https://cdn.bitmovin.com/player/android/3/docs/index.html)
+* [Hexagon](https://hexagontk.com/stable/api/)
+* [Ktor](https://api.ktor.io/)
+* [OkHttp](https://square.github.io/okhttp/5.x/okhttp/okhttp3/)
+* [Gradle](https://docs.gradle.org/current/kotlin-dsl/index.html)
## Generate HTML documentation
HTML as an output format is supported by all runners. To generate HTML documentation, follow these steps depending on
your build tool or runner:
-* For [Gradle](dokka-gradle.md#generate-documentation), run `dokkaHtml` or `dokkaHtmlMultiModule` tasks.
-
- > These instructions reflect Dokka Gradle plugin v1 configuration and tasks. Starting from Dokka 2.0.0, [the Gradle tasks to generate documentation changed](dokka-migration.md#generate-documentation-with-the-updated-task).
- >
- > For more details and the full list of changes in Dokka Gradle Plugin v2, see the [Migration guide](dokka-migration.md).
- >
- {style="note"}
-
+* For [Gradle](dokka-gradle.md#generate-documentation), run the following tasks:
+ * `dokkaGenerate` to generate documentation in [all available formats based on the applied plugins](dokka-gradle.md#configure-documentation-output-format).
+ This is the recommended task for most users. When using this task in IntelliJ IDEA, it logs a clickable link to the output.
+ * `dokkaGeneratePublicationHtml` to generate documentation only in HTML format. This task exposes the output directory
+ as an `@OutputDirectory`. Use this task when you need to consume the generated files in other Gradle tasks, such
+ as uploading them to a server, moving them into a GitHub Pages directory, or packaging them into a `javadoc.jar`.
+ This task is intentionally not shown in Gradle task groups because it is not meant for everyday use.
* For [Maven](dokka-maven.md#generate-documentation), run the `dokka:dokka` goal.
* For [CLI runner](dokka-cli.md#generate-documentation), run with HTML dependencies set.
@@ -32,62 +43,26 @@ your build tool or runner:
## Configuration
-HTML format is Dokka's base format, so it is configurable through `DokkaBase` and `DokkaBaseConfiguration`
-classes:
+HTML format is Dokka's base format, and you can include configuration options:
-Via type-safe Kotlin DSL:
-
```kotlin
-import org.jetbrains.dokka.base.DokkaBase
-import org.jetbrains.dokka.gradle.DokkaTask
-import org.jetbrains.dokka.base.DokkaBaseConfiguration
-
-buildscript {
- dependencies {
- classpath("org.jetbrains.dokka:dokka-base:%dokkaVersion%")
- }
-}
-
-tasks.withType().configureEach {
- pluginConfiguration {
- customAssets = listOf(file("my-image.png"))
- customStyleSheets = listOf(file("my-styles.css"))
- footerMessage = "(c) 2022 MyOrg"
- separateInheritedMembers = false
- templatesDir = file("dokka/templates")
- mergeImplicitExpectActualDeclarations = false
+// build.gradle.kts
+
+dokka {
+ pluginsConfiguration.html {
+ customAssets.from("logo.png")
+ customStyleSheets.from("styles.css")
+ footerMessage.set("(c) Your Company")
+ separateInheritedMembers.set(false)
+ templatesDir.set(file("dokka/templates"))
+ mergeImplicitExpectActualDeclarations.set(false)
}
}
```
-Via JSON:
-
-```kotlin
-import org.jetbrains.dokka.gradle.DokkaTask
-
-tasks.withType().configureEach {
- val dokkaBaseConfiguration = """
- {
- "customAssets": ["${file("assets/my-image.png")}"],
- "customStyleSheets": ["${file("assets/my-styles.css")}"],
- "footerMessage": "(c) 2022 MyOrg",
- "separateInheritedMembers": false,
- "templatesDir": "${file("dokka/templates")}",
- "mergeImplicitExpectActualDeclarations": false
- }
- """
- pluginsMapConfiguration.set(
- mapOf(
- // fully qualified plugin name to json configuration
- "org.jetbrains.dokka.base.DokkaBase" to dokkaBaseConfiguration
- )
- )
-}
-```
-
@@ -173,7 +148,7 @@ Via [JSON configuration](dokka-cli.md#run-with-json-configuration):
### Configuration options
-The table below contains all of the possible configuration options and their purpose.
+The table below contains all the possible configuration options and their purpose:
| **Option** | **Description** |
|-----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
@@ -213,8 +188,16 @@ You can provide your own images to be bundled with documentation by using the `c
These files are copied to the `
By default, it is deduced from languageVersion.
-
-
- Whether to generate external documentation links that lead to the API reference
- documentation of Kotlin's standard library.
-
- Note: Links are generated when noStdLibLink is set to false.
- Default: false
-
-
- Whether to generate external documentation links to JDK's Javadocs.
- The version of JDK Javadocs is determined by the jdkVersion option.
- Note: Links are generated when noJdkLink is set to false.
- Default: false
-
-
-
- Whether to generate external documentation links to the Android SDK API reference.
- This is only relevant in Android projects, ignored otherwise.
- Note: Links are generated when noAndroidSdkLink is set to false.
- Default: false
-
-
-
- A list of Markdown files that contain
- module and package documentation.
-
- The contents of the specified files are parsed and embedded into documentation as module and package descriptions.
-
- See Dokka gradle example
- for an example of what it looks like and how to use it.
-
-
-
-
- The platform to be used for setting up code analysis and
- @sample environment.
-
- The default value is deduced from information provided by the Kotlin Gradle plugin.
-
The source code roots to be analyzed and documented.
@@ -1072,7 +1014,7 @@ tasks.withType(DokkaTask.class) {
The classpath for analysis and interactive samples.
This is useful if some types that come from dependencies are not resolved/picked up automatically.
This option accepts both .jar and .klib files.
- By default, classpath is deduced from information provided by the Kotlin Gradle plugin.
+ By default, the classpath is deduced from information provided by the Kotlin Gradle plugin.
@@ -1084,8 +1026,13 @@ tasks.withType(DokkaTask.class) {
### Source link configuration
+Configure source links
+to allow navigation from the generated documentation to the corresponding source code in a remote repository.
+Use the `dokkaSourceSets.main{}` block for this configuration.
+
The `sourceLinks` configuration block allows you to add a `source` link to each signature
-that leads to the `remoteUrl` with a specific line number. (The line number is configurable by setting `remoteLineSuffix`).
+that leads to the `remoteUrl` with a specific line number.
+The line number is configurable by setting `remoteLineSuffix`.
This helps readers to find the source code for each declaration.
@@ -1093,35 +1040,53 @@ For an example, see the documentation for the
[`count()`](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/count.html)
function in `kotlinx.coroutines`.
-
-
+The syntax of `build.gradle.kts` files differs from regular `.kt`
+files (such as those used for custom Gradle plugins) because Gradle's Kotlin DSL uses type-safe accessors:
+
+
+
```kotlin
-import org.jetbrains.dokka.gradle.DokkaTask
-import java.net.URL
+// build.gradle.kts
-// Note: To configure multi-project builds, you need
-// to configure Partial tasks of the subprojects.
-// See "Configuration example" section of documentation.
-tasks.withType().configureEach {
- // ..
- // general configuration section
- // ..
-
- dokkaSourceSets.configureEach {
- // ..
- // source set configuration section
- // ..
-
+dokka {
+ dokkaSourceSets.main {
sourceLink {
- localDirectory.set(projectDir.resolve("src"))
- remoteUrl.set(URL("https://github.com/kotlin/dokka/tree/master/src"))
+ localDirectory.set(file("src/main/kotlin"))
+ remoteUrl("https://github.com/your-repo")
remoteLineSuffix.set("#L")
}
}
}
```
+
+
+
+```kotlin
+// CustomPlugin.kt
+
+import org.gradle.api.Plugin
+import org.gradle.api.Project
+import org.jetbrains.dokka.gradle.DokkaExtension
+
+abstract class CustomPlugin : Plugin {
+ override fun apply(project: Project) {
+ project.plugins.apply("org.jetbrains.dokka")
+ project.extensions.configure(DokkaExtension::class.java) { dokka ->
+ dokka.dokkaSourceSets.named("main") { dss ->
+ dss.includes.from("README.md")
+ dss.sourceLink {
+ it.localDirectory.set(project.file("src/main/kotlin"))
+ it.remoteUrl("https://example.com/src")
+ it.remoteLineSuffix.set("#L")
+ }
+ }
+ }
+ }
+}
+```
+
@@ -1189,36 +1154,51 @@ tasks.withType(DokkaTask.class) {
+Since the source link configuration has [changed](https://docs.gradle.org/current/userguide/upgrading_version_8.html#deprecated_invalid_url_decoding),
+use the `URI` class to specify the remote URL:
+
+```kotlin
+remoteUrl.set(URI("https://github.com/your-repo"))
+
+// or
+
+remoteUrl("https://github.com/your-repo")
+```
+
+Additionally,
+you can use two [utility functions](https://github.com/Kotlin/dokka/blob/220922378e6c68eb148fda2ec80528a1b81478c9/dokka-runners/dokka-gradle-plugin/src/main/kotlin/engine/parameters/DokkaSourceLinkSpec.kt#L82-L96)
+for setting the URL:
+
+```kotlin
+fun remoteUrl(@Language("http-url-reference") value: String): Unit =
+ remoteUrl.set(URI(value))
+
+// and
+
+fun remoteUrl(value: Provider): Unit =
+ remoteUrl.set(value.map(::URI))
+```
+
### Package options
-The `perPackageOption` configuration block allows setting some options for specific packages matched by `matchingRegex`.
+The `perPackageOption` configuration block allows setting some options for specific packages matched by `matchingRegex`:
```kotlin
-import org.jetbrains.dokka.DokkaConfiguration.Visibility
-import org.jetbrains.dokka.gradle.DokkaTask
+import org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier
-// Note: To configure multi-project builds, you need
-// to configure Partial tasks of the subprojects.
-// See "Configuration example" section of documentation.
-tasks.withType().configureEach {
- // ..
- // general configuration section
- // ..
-
- dokkaSourceSets.configureEach {
- // ..
- // source set configuration section
- // ..
-
- perPackageOption {
- matchingRegex.set(".*api.*")
- suppress.set(false)
- skipDeprecated.set(false)
- reportUndocumented.set(false)
- documentedVisibilities.set(setOf(Visibility.PUBLIC))
+dokka {
+ dokkaPublications.html {
+ dokkaSourceSets.configureEach {
+ perPackageOption {
+ matchingRegex.set(".*api.*")
+ suppress.set(false)
+ skipDeprecated.set(false)
+ reportUndocumented.set(false)
+ documentedVisibilities.set(setOf(VisibilityModifier.Public)) // OR documentedVisibilities(VisibilityModifier.Public)
+ }
}
}
}
@@ -1269,7 +1249,7 @@ tasks.withType(DokkaTask.class) {
Whether to document declarations annotated with @Deprecated.
- This can be configured on source set level.
+ This can be configured on the source set level.
Default: false
@@ -1278,23 +1258,30 @@ tasks.withType(DokkaTask.class) {
after they have been filtered by documentedVisibilities and other filters.
This setting works well with failOnWarning.
- This can be configured on source set level.
+ This can be configured on the source set level.
Default: false
- The set of visibility modifiers that should be documented.
+ Defines which visibility modifiers Dokka should include in the generated documentation.
+
+ Use them if you want to document Protected/Internal/Private
+ declarations within this package,
+ as well as if you want to exclude Public declarations and only document internal API.
+
- This can be used if you want to document protected/internal/private declarations within this package,
- as well as if you want to exclude public declarations and only document internal API.
+ Additionally, you can use Dokka's
+ documentedVisibilities() function
+ to add documented visibilities.
- This can be configured on source set level.
- Default: DokkaConfiguration.Visibility.PUBLIC
+ This can be configured on the source set level.
+ Default: VisibilityModifier.Public
### External documentation links configuration
-The `externalDocumentationLink` block allows the creation of links that lead to the externally hosted documentation of
+The `externalDocumentationLinks {}`
+block allows the creation of links that lead to the externally hosted documentation of
your dependencies.
For example, if you are using types from `kotlinx.serialization`, by default they are unclickable in your
@@ -1303,33 +1290,20 @@ is built by Dokka and is [published on kotlinlang.org](https://kotlinlang.org/ap
configure external documentation links for it. Thus allowing Dokka to generate links for types from the library, making
them resolve successfully and clickable.
-By default, external documentation links for Kotlin standard library, JDK, Android SDK and AndroidX are configured.
+By default, external documentation links for Kotlin standard library, JDK, Android SDK, and AndroidX are configured.
+
+Register external documentation links using the `register()` method to define each link.
+The `externalDocumentationLinks` API uses this method aligning with Gradle DSL conventions:
```kotlin
-import org.jetbrains.dokka.gradle.DokkaTask
-import java.net.URL
-
-// Note: To configure multi-project builds, you need
-// to configure Partial tasks of the subprojects.
-// See "Configuration example" section of documentation.
-tasks.withType().configureEach {
- // ..
- // general configuration section
- // ..
-
+dokka {
dokkaSourceSets.configureEach {
- // ..
- // source set configuration section
- // ..
-
- externalDocumentationLink {
- url.set(URL("https://kotlinlang.org/api/kotlinx.serialization/"))
- packageListUrl.set(
- rootProject.projectDir.resolve("serialization.package.list").toURL()
- )
+ externalDocumentationLinks.register("example-docs") {
+ url("https://example.com/docs/")
+ packageListUrl("https://example.com/docs/package-list")
}
}
}
@@ -1387,7 +1361,7 @@ tasks.withType(DokkaTask.class) {
Package lists contain information about the documentation and the project itself,
- such as module and package names.
+ such as subproject and package names.
This can also be a locally cached file to avoid network calls.
@@ -1395,38 +1369,41 @@ tasks.withType(DokkaTask.class) {
### Complete configuration
-Below you can see all possible configuration options applied at the same time.
+Below you can see all possible configuration options applied at the same time:
```kotlin
-import org.jetbrains.dokka.DokkaConfiguration.Visibility
-import org.jetbrains.dokka.gradle.DokkaTask
-import org.jetbrains.dokka.Platform
-import java.net.URL
+import org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier
-// Note: To configure multi-project builds, you need
-// to configure Partial tasks of the subprojects.
-// See "Configuration example" section of documentation.
-tasks.withType().configureEach {
- moduleName.set(project.name)
- moduleVersion.set(project.version.toString())
- outputDirectory.set(layout.buildDirectory.dir("dokka/$name"))
- failOnWarning.set(false)
- suppressObviousFunctions.set(true)
- suppressInheritedMembers.set(false)
- offlineMode.set(false)
+plugins {
+ id("org.jetbrains.dokka") version "%dokkaVersion%"
+}
+
+dokka {
+ dokkaPublications.html {
+ moduleName.set(project.name)
+ moduleVersion.set(project.version.toString())
+ outputDirectory.set(layout.buildDirectory.dir("dokka/html"))
+ failOnWarning.set(false)
+ suppressInheritedMembers.set(false)
+ offlineMode.set(false)
+ suppressObviousFunctions.set(true)
+ includes.from(project.files(), "packages.md", "extra.md")
+ }
dokkaSourceSets {
+ // Example: Configuration exclusive to the 'linux' source set
named("linux") {
- dependsOn("native")
+ dependentSourceSets{named("native")}
sourceRoots.from(file("linux/src"))
}
+
configureEach {
suppress.set(false)
displayName.set(name)
- documentedVisibilities.set(setOf(Visibility.PUBLIC))
+ documentedVisibilities.set(setOf(VisibilityModifier.Public)) // OR documentedVisibilities(VisibilityModifier.Public)
reportUndocumented.set(false)
skipEmptyPackages.set(true)
skipDeprecated.set(false)
@@ -1434,26 +1411,19 @@ tasks.withType().configureEach {
jdkVersion.set(8)
languageVersion.set("1.7")
apiVersion.set("1.7")
- noStdlibLink.set(false)
- noJdkLink.set(false)
- noAndroidSdkLink.set(false)
- includes.from(project.files(), "packages.md", "extra.md")
- platform.set(Platform.DEFAULT)
sourceRoots.from(file("src"))
classpath.from(project.files(), file("libs/dependency.jar"))
samples.from(project.files(), "samples/Basic.kt", "samples/Advanced.kt")
-
+
sourceLink {
- localDirectory.set(projectDir.resolve("src"))
- remoteUrl.set(URL("https://github.com/kotlin/dokka/tree/master/src"))
+ localDirectory.set(file("src/main/kotlin"))
+ remoteUrl("https://example.com/src")
remoteLineSuffix.set("#L")
}
- externalDocumentationLink {
- url.set(URL("https://kotlinlang.org/api/core/kotlin-stdlib/"))
- packageListUrl.set(
- rootProject.projectDir.resolve("stdlib.package.list").toURL()
- )
+ externalDocumentationLinks {
+ url = URL("https://example.com/docs/")
+ packageListUrl = File("/path/to/package-list").toURI().toURL()
}
perPackageOption {
@@ -1463,11 +1433,11 @@ tasks.withType().configureEach {
reportUndocumented.set(false)
documentedVisibilities.set(
setOf(
- Visibility.PUBLIC,
- Visibility.PRIVATE,
- Visibility.PROTECTED,
- Visibility.INTERNAL,
- Visibility.PACKAGE
+ VisibilityModifier.Public,
+ VisibilityModifier.Private,
+ VisibilityModifier.Protected,
+ VisibilityModifier.Internal,
+ VisibilityModifier.Package
)
)
}
@@ -1499,7 +1469,7 @@ tasks.withType(DokkaTask.class) {
dokkaSourceSets {
named("linux") {
- dependsOn("native")
+ dependentSourceSets{named("native")}
sourceRoots.from(file("linux/src"))
}
configureEach {