'How can I add a footer to Kotlin Dokka docs?
I am looking for a way to include text in the footer of all Dokka generated docs. I am not seeing this option being advertised by the Gradle or Maven plugins for Dokka.
Is this possible? Can you point me to a sample?
Solution 1:[1]
There are two instance methods in dokka
package – one for footer
, one for header
:
fun appendFooter(to:) { }
fun appendHeader(to:, title:, basePath:) { }
Here's a real code how it looks like:
package org.jetbrains.dokka
import java.io.File
interface HtmlTemplateService {
fun appendHeader(to: StringBuilder, title: String?, basePath: File)
fun appendFooter(to: StringBuilder)
companion object {
fun default(css: String? = null): HtmlTemplateService {
return object : HtmlTemplateService {
override fun appendFooter(to: StringBuilder) {
if (!to.endsWith('\n')) {
to.append('\n')
}
to.appendln("</BODY>")
to.appendln("</HTML>")
}
override fun appendHeader(to: StringBuilder, title: String?, basePath: File) {
to.appendln("<HTML>")
to.appendln("<HEAD>")
to.appendln("<meta charset=\"UTF-8\">")
if (title != null) {
to.appendln("<title>$title</title>")
}
if (css != null) {
val cssPath = basePath.resolve(css)
to.appendln("<link rel=\"stylesheet\" href=\"$cssPath\">")
}
to.appendln("</HEAD>")
to.appendln("<BODY>")
}
}
}
}
}
I think it must be working even in dokka.playground.
Hope this helps.
Solution 2:[2]
You can set your own footer by overriding the Dokka footer message.
{module}/build.gradle
tasks.named("dokkaHtml").configure {
pluginsMapConfiguration.set(
[
"org.jetbrains.dokka.base.DokkaBase": """{
"footerMessage": "Your New Footer!"
}"""
]
)
}
This will replace the Copyright 20xx
in the current footer.
For further details on multi-module / css support, recommend checking out the source below.
Source: Raywenderlich
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 |