0

With Dokka 1.8.10 i got Problemsto show the private functions of my classes. I tried includeNonPublic.set(true) with an older version (which worked) but for 1.8.10 this mehtod is deprecated...

I'm searchin for an solution, that shows my private functions in the classes.

So this is my code in the build.gradle (:app)

I think this are the relevant parts.

import org.jetbrains.dokka.gradle.DokkaTask



plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'org.jetbrains.dokka' version '1.8.10'
}

...

dependencies {
    implementation platform('androidx.compose:compose-bom:2023.01.00')
    debugImplementation "androidx.compose.ui:ui-test-manifest"
    debugImplementation "androidx.compose.ui:ui-tooling"
    implementation 'androidx.activity:activity-compose:1.6.1'
    implementation "androidx.compose.material:material"
    implementation "androidx.compose.ui:ui"
    implementation "androidx.compose.ui:ui-tooling-preview"
    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
    dokkaPlugin 'org.jetbrains.dokka:android-documentation-plugin:1.8.10'
}

...

// Configure all single-project Dokka tasks at the same time,
// such as dokkaHtml, dokkaJavadoc and dokkaGfm.
tasks.withType(DokkaTask.class) {

    moduleName.set(project.name)
    moduleVersion.set(project.version.toString())
    outputDirectory.set(file("build/dokka/$name"))
    failOnWarning.set(false)
    suppressObviousFunctions.set(true)
    suppressInheritedMembers.set(true)
    offlineMode.set(false)

    dokkaSourceSets.configureEach {
        /*documentedVisibilities.set([
                DokkaConfiguration.Visibility.PUBLIC,
                DokkaConfiguration.Visibility.PROTECTED
        ])*/

        perPackageOption {
            matchingRegex.set(".*internal.*")
            suppress.set(true)
            //documentedVisibilities.set([Visibility.PRIVATE])
        }
    }
}

dokkaHtml {
    outputDirectory.set(file("build/documentation/html"))
}


tasks.dokkaHtml.configure {
    dokkaSourceSets {
        configureEach {
            // A set of visibility modifiers that should be documented
            // If set by user, overrides includeNonPublic. Default is PUBLIC
            documentedVisibilities.set(listOf(DokkaConfiguration.Visibility.PRIVATE) + documentedVisibilities.get())


            //includeNonPublic.set(true)
            skipDeprecated.set(true)
            reportUndocumented.set(true)
            noAndroidSdkLink.set(false)
        }
    }
}
Dimitry Ernot
  • 6,256
  • 2
  • 25
  • 37
Niklas
  • 1

1 Answers1

0

For Gradle with Kotlin DSL, use:

documentedVisibilities.set(listOf(DokkaConfiguration.Visibility.PRIVATE)
                           + documentedVisibilities.get())

(it seems the add method does not work properly)

Gradle with Groovy syntax:

documentedVisibilities.set([DokkaConfiguration.Visibility.PRIVATE])

Maven:

<puglin>
    <groupId>org.jetbrains.dokka</groupId>
    <artifactId>dokka-maven-plugin</artifactId>
    <version>0.9.15</version>
    <configuration>
       <includeNonPublic>true</includeNonPublic>
    </configuration>
</plugin>
Dimitry Ernot
  • 6,256
  • 2
  • 25
  • 37
  • Hey Dimitry, thanks for your answer. It still don't work... :( I get the issue, that there is a problem with the property 'unsuppressedSourceSets'. In the next answer i try to show my code. – Niklas Apr 23 '23 at 14:19
  • Can you post the exact error you got? – Dimitry Ernot Apr 24 '23 at 08:54
  • I already fixed the issue. Instead of listOf() i put my Visibilities in [ ] and it worked. – Niklas Apr 25 '23 at 07:41
  • I just saw you're using the groovy syntax and not the kotlin DSL. I changed my answer to cover all cases. Feel free to update it with something is missing – Dimitry Ernot Apr 25 '23 at 08:13
  • Nono, it's working fine now. Thank you for that! Now i got another problem. My classes get printed 5 times in the HTML-Output. But i think it is a problem with the flavors or buliding variants of our app. – Niklas Apr 25 '23 at 08:20