5

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?

Roland
  • 22,259
  • 4
  • 57
  • 84
Antoine Toulme
  • 937
  • 4
  • 15

2 Answers2

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

Shazbot
  • 1,444
  • 1
  • 11
  • 21
  • Does anyone have documentation showing all they keys we can set here? I know that Ray W. link shows `footerMessage` and `customStyleSheets`, but is there anything else? – TJ Olsen Jun 09 '22 at 21:33
0

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.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
  • I'm not sure what I'm looking at. Your first link points to a commit log, the second to a test file. The code you include is an interface with a companion object - how is that called from gradle? – Antoine Toulme May 06 '19 at 17:10
  • The main link is first one (the second link is just an example showing that you might test this code in Dokka playground). And, honestly, I don't realise how to call it from gradle... That's all that I could find on Dokka's footer. – Andy Jazz May 06 '19 at 18:15
  • I'm sorry this is not meeting the criteria of the bounty :| Thanks for your help. – Antoine Toulme May 07 '19 at 00:49