Get started with Dokka
Below you can find simple instructions to help you get started with Dokka.
Apply the Gradle Dokka plugin
Apply the Dokka Gradle plugin (DGP) in the root build script of your project:
Document multi-project builds
When documenting multi-project builds, 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.
Generate documentation
To generate documentation, run the following Gradle task:
This task works for both single and multi-project builds.
Run the dokkaGenerate task from the aggregating project by prefixing the task with its project path (:). For example:
Avoid running ./gradlew dokkaGenerate instead of ./gradlew :dokkaGenerate or ./gradlew :aggregatingProject:dokkaGenerate. Without a project path (:) prefixing the task, Gradle tries to run all dokkaGenerate tasks across the entire build, which may trigger unnecessary work.
You can use different tasks to generate output in HTML, Javadoc or both HTML and Javadoc.
Apply the Gradle Dokka plugin
Apply the Gradle plugin for Dokka in the root build script of your project:
Document multi-project builds
When documenting multi-project builds, 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.
Generate documentation
To generate documentation, run the following Gradle task:
This task works for both single and multi-project builds.
Run the dokkaGenerate task from the aggregating project by prefixing the task with its project path. For example:
Avoid running ./gradlew dokkaGenerate instead of ./gradlew :dokkaGenerate or ./gradlew :aggregatingProject:dokkaGenerate. Without a project path (:) prefixing the task, Gradle tries to run all dokkaGenerate tasks across the entire build, which may trigger unnecessary work.
You can use different tasks to generate output in HTML, Javadoc or both HTML and Javadoc.
Add the Maven plugin for Dokka to the plugins section of your POM file:
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 Maven.