Main
Main
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.
If you want to learn how to create Dokka plugins, see Developer guides.
Let's have a look at how you can apply the mathjax plugin to your project:
Kotlin
Groovy
Maven
CLI
The Gradle plugin for Dokka creates convenient dependency configurations that allow you to
apply plugins universally or for a specific output format only.
dependencies {
// Is applied universally
dokkaPlugin("org.jetbrains.dokka:mathjax-plugin:1.9.10")
Let's have a look at how you can configure the DokkaBase plugin, which is responsible for
generating HTML 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):
Kotlin
Groovy
Maven
CLI
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:
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:1.9.10")
}
}
tasks.withType<DokkaTask>().configureEach {
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
customAssets = listOf(file("my-image.png"))
customStyleSheets = listOf(file("my-styles.css"))
footerMessage = "(c) 2022 MyOrg"
}
}
Alternatively, plugins can be configured via JSON. With this method, no additional
dependencies are needed.
import org.jetbrains.dokka.gradle.DokkaTask
tasks.withType<DokkaTask>().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
)
)
}