Dokka - skip javadoc generator for default packages for Android

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

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

Then I completed the basic configuration of the following project instructions:

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

I am creating documentation using the basic gradle command:

 [ user@linux AppDir]$ bash gradlew dokka 

The output is fine, but it includes several directories from android or plugins that I added to my project, for example:

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

How to skip these packages? Is there a way to create a dock only for the my / app / scr / java folder and the files I created? Any help is appreciated.

+8
source share
3 answers

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

In version 0.9.15, the next commit seemed to turn to " Suppress the output of android.R and other generated files in dokka-android ", but apparently, after creating the suppresedFiles map with the necessary information, it was not used to filter sourceSets .


UPDATE : Dokka 0.9.16 was released with a fix, among other improvements.

# 224 Filtered classes created by Android from documents

+2
source

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 are using Android, then the type is important: org.jetbrains.dokka.gradle.DokkaAndroidTask

Not DokkaTask , but DokkaAndroidTask .

+2
source

create a gradle task to remove the necessary โ€œmissingโ€ packages:

 task dokkaJavaDoc(type: org.jetbrains.dokka.gradle.DokkaTask) { outputFormat = 'javadoc' outputDirectory = "$rootDir/docs" } task deleteUnusedDokkaAssets(type: Delete) { file("$rootDir/docs").listFiles().each { if( it.name.contains("android.R" ) ) project.delete it if( it.name.contains("android.support" ) ) project.delete it if( it.name.contains("com.google" ) ) project.delete it if( it.name.contains("com.crashlytics" ) ) project.delete it } } 
+1
source

Source: https://habr.com/ru/post/1271610/


All Articles