8

I am trying to use Dokka plugin to generate Javadoc for android Kotlin application. I added the plugin to my gradle:

classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.15"

Then I made a basic configuration following project instructions:

dokka {
    outputFormat = 'javadoc'
    outputDirectory = "$rootDir/docs"
    skipEmptyPackages = true
    noStdlibLink = true
}

I generate documentation using basic gradle command:

[user@linux AppDir]$ bash gradlew dokka

Output is fine, but it includes multiple directories from android or plugins I have added to my project, for example:

android.R
android.support
com.google
com.crashlytics
.
.
.
etc.

How do I skip these packages? Is there any way to generate dock only for my /app/scr/java folder, and files I created? Any help is appreciated.

ikurek
  • 604
  • 11
  • 27

2 Answers2

2

Dokka version 0.9.16 will include a bugfix to remove generated files from documentation.

In version 0.9.15, the following commit seemed to address that "Suppress output of android.R and other generated stuff in dokka-android", but apparently after creating the suppresedFiles map with the needed information, it was not really used to filter sourceSets.


UPDATE: Dokka 0.9.16 has been released with the fix, among other improvements.

#224 Filtered out Android generated classes from docs

Xavier Rubio Jansana
  • 6,388
  • 1
  • 27
  • 50
2

Here is a working example with Dokka 0.9.16:

task dokka(overwrite: true, type: org.jetbrains.dokka.gradle.DokkaAndroidTask) {
    outputFormat = 'javadoc'
    outputDirectory = "$buildDir/docs"

    // Do not create index pages for empty packages
    skipEmptyPackages = true

    //Do not output deprecated members. Applies globally, can be overridden by packageOptions
    skipDeprecated = false

    //No default documentation link to kotlin-stdlib
    noStdlibLink = false
}

If you use Android then the type is important: org.jetbrains.dokka.gradle.DokkaAndroidTask

Not DokkaTask but DokkaAndroidTask.

halfer
  • 19,824
  • 17
  • 99
  • 186
Paul Spiesberger
  • 5,630
  • 1
  • 43
  • 53
  • 1
    You'll also need to use the `org.jetbrains.dokka-android` plugin from the `org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.16` repository! Took me a looong time to figure that out. – Chris Watts Nov 01 '18 at 21:27