gitmyhub

dokka

Kotlin ★ 3.8k updated 1d ago

API documentation engine for Kotlin

Dokka is the official documentation generator for Kotlin, built and maintained by JetBrains, the company behind the Kotlin language. It reads the comment blocks that developers write inside their Kotlin or Java source code and turns them into polished API reference pages. If you have ever browsed the online documentation for a Kotlin library and seen an organized list of classes, functions, and their descriptions, there is a good chance Dokka produced it.

The tool understands two comment styles: KDoc, which is Kotlin's own documentation format, and Javadoc, the format used in Java code. This means projects that mix both languages, a common setup in Android development, work without any special configuration. Dokka can output documentation in several formats: its own HTML format (the default and most fully featured), Markdown in GitHub Flavored or Jekyll style, and a Javadoc-compatible HTML format that mirrors what the Java ecosystem expects. The Markdown and Javadoc output modes are currently marked as Alpha and may have rough edges.

You add Dokka to a project by installing it as a Gradle or Maven plugin. For Gradle projects, a few lines in the build script are enough to get started, and running a single task produces the HTML output in a build folder. Maven users add a plugin entry to their POM file and run a goal. A command-line runner also exists for situations where neither build tool is in play, though its setup is more involved. Dokka also ships a dedicated Android plugin that adjusts the documentation experience for Android-specific APIs.

Several well-known Kotlin and Java projects use Dokka for their public documentation, including Ktor, OkHttp, and the Gradle Kotlin DSL docs. The tool is built to be extended: a plugin system lets teams add custom output formats, preprocessing steps, or other behaviors beyond what ships out of the box.