Awesome
Dokka
Dokka is an API documentation engine for Kotlin.
Just like Kotlin itself, Dokka supports mixed-language projects. It understands Kotlin's KDoc comments and Java's Javadoc comments.
Dokka can generate documentation in multiple formats, including its own modern HTML format, multiple flavors of Markdown, and Java's Javadoc HTML.
Some libraries that use Dokka for their API reference documentation:
You can run Dokka using Gradle, Maven or from the command line. It is also highly pluggable.
Documentation
Comprehensive documentation for Dokka is available on kotlinlang.org
Get started with Dokka
Gradle
<details open> <summary>Kotlin DSL</summary>Apply the Gradle plugin for Dokka in the root build script of your project:
plugins {
id("org.jetbrains.dokka") version "1.9.20"
}
When documenting multi-project builds, you need to apply the Gradle plugin for Dokka within subprojects as well:
subprojects {
apply(plugin = "org.jetbrains.dokka")
}
</details>
<details>
<summary>Groovy DSL</summary>
Apply Gradle plugin for Dokka in the root project:
plugins {
id 'org.jetbrains.dokka' version '1.9.20'
}
When documenting multi-project builds, you need to apply the Gradle plugin for Dokka within subprojects as well:
subprojects {
apply plugin: 'org.jetbrains.dokka'
}
</details>
To generate documentation, run the following Gradle tasks:
dokkaHtml
for single-project buildsdokkaHtmlMultiModule
for multi-project builds
By default, the output directory is set to /build/dokka/html
and /build/dokka/htmlMultiModule
respectively.
To learn more about the Gradle plugin for Dokka, see documentation for Gradle.
Maven
Add the Dokka Maven plugin to the plugins
section of your POM file:
<build>
<plugins>
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
<version>1.9.20</version>
<executions>
<execution>
<phase>pre-site</phase>
<goals>
<goal>dokka</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
To generate documentation, run the dokka:dokka
goal.
By default, the output directory is set to target/dokka
.
To learn more about using Dokka with Maven, see documentation for Maven.
CLI
It is possible to run Dokka from the command line without having to use any of the build tools, but it's more difficult to set up and for that reason it is not covered in this section.
Please consult documentation for the command line runner to learn how to use it.
Android
In addition to applying and configuring Dokka, you can apply Dokka's Android documentation plugin, which aims to improve documentation experience on the Android platform:
<details open> <summary>Gradle Kotlin DSL</summary>dependencies {
dokkaPlugin("org.jetbrains.dokka:android-documentation-plugin:1.9.20")
}
</details>
<details>
<summary>Gradle Groovy DSL</summary>
dependencies {
dokkaPlugin 'org.jetbrains.dokka:android-documentation-plugin:1.9.20'
}
</details>
<details>
<summary>Maven</summary>
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
...
<configuration>
<dokkaPlugins>
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>android-documentation-plugin</artifactId>
<version>1.9.20</version>
</plugin>
</dokkaPlugins>
</configuration>
</plugin>
</details>
Output formats
HTML
HTML is Dokka's default and recommended output format. You can see an example of the output by browsing documentation for kotlinx.coroutines.
HTML format is configurable and, among other things, allows you to modify stylesheets, add custom image assets, change footer message and revamp the structure of the generated HTML pages through templates.
For more details and examples, see documentation for HTML format.
Markdown
Dokka is able to generate documentation in GitHub Flavored and Jekyll compatible Markdown. However, both of these formats are still in Alpha, so you might encounter bugs and migration issues.
For more details and examples, see documentation for Markdown formats.
Javadoc
Dokka's Javadoc output format is a lookalike of Java's Javadoc HTML format. This format is still in Alpha, so you might encounter bugs and migration issues.
Javadoc format tries to visually mimic HTML pages generated by the Javadoc tool, but it's not a direct implementation or an exact copy. In addition, all Kotlin signatures are translated to Java signatures.
For more details and examples, see documentation for Javadoc format.
Dokka plugins
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.
Learn more about Dokka plugins and their configuration in Dokka plugins.
If you want to learn how to develop Dokka plugins, see Developer guides.
Community
Dokka has a dedicated #dokka
channel in Kotlin Community Slack
where you can chat about Dokka, its plugins and how to develop them, as well as get in touch with maintainers.