Javadoc

The Javadoc output format is still in Alpha, so you may find bugs and experience migration issues when using it. Successful integration with tools that accept Java’s Javadoc HTML as input is not guaranteed. You use it at your own risk.

Javadoc - 图1

Dokka’s Javadoc output format is a lookalike of Java’s Javadoc HTML format.

It tries to visually mimic HTML pages generated by the Javadoc tool, but it’s not a direct implementation or an exact copy.

Screenshot of javadoc output format

All Kotlin code and signatures are rendered as seen from Java’s perspective. This is achieved with our Kotlin as Java Dokka plugin, which comes bundled and applied by default for this format.

The Javadoc output format is implemented as a Dokka plugin, and it is maintained by the Dokka team. It is open source and you can find the source code on GitHub.

Generate Javadoc documentation

The Javadoc format does not support multiplatform projects.

Javadoc - 图3

【Gradle】

The Gradle plugin for Dokka comes with the Javadoc output format included. You can use the following tasks:

TaskDescription
dokkaJavadocGenerates Javadoc documentation for a single project.
dokkaJavadocCollectorA Collector task created only for parent projects in multi-project builds. It calls dokkaJavadoc for every subproject and merges all outputs into a single virtual project.

The javadoc.jar file can be generated separately. For more information, see Building javadoc.jar.

【Maven】

The Maven plugin for Dokka comes with the Javadoc output format built in. You can generate documentation by using the following goals:

GoalDescription
dokka:javadocGenerates documentation in Javadoc format
dokka:javadocJarGenerates a javadoc.jar file that contains documentation in Javadoc format

【CLI】

Since the Javadoc output format is a Dokka plugin, you need to download the plugin’s JAR file.

The Javadoc output format has two dependencies that you need to provide as additional JAR files:

Via command line options:

  1. java -jar dokka-cli-1.7.20.jar \
  2. -pluginsClasspath "./dokka-base-1.7.20.jar;...;./javadoc-plugin-1.7.20.jar" \
  3. ...

Via JSON configuration:

  1. {
  2. ...
  3. "pluginsClasspath": [
  4. "./dokka-base-1.7.20.jar",
  5. "...",
  6. "./kotlin-as-java-plugin-1.7.20.jar",
  7. "./korte-jvm-3.3.0.jar",
  8. "./javadoc-plugin-1.7.20.jar"
  9. ],
  10. ...
  11. }

For more information, see Other output formats in the CLI runner’s documentation.