0

Did anyone encounter the same issue? When using Dokka to document a data class

/**
 * Data class for which we want documentation
 */
data class DokkaData(
    /** A String value */
    val aString: String,
    /** An Integer value */
    val anInt: Int,
    /** Yes, a Boolean value. My favorite. */
    val aBoolean: Boolean) {

    /**
     * Checks that all values are representation of `1`
     */
    fun isOne() = aString == "1" && anInt == 1 && aBoolean
}

the documentation is correctly displayed in Android Studio Documentation correctly displayed

Documentation correctly displayed

But then, when exporting library to mavenLocal using dokkaJavadoc:

plugins {
    id 'com.android.library'
    id 'kotlin-android'
    id 'maven-publish'
    id("org.jetbrains.dokka") version "1.6.10"
}

android {
    compileSdk 31

    defaultConfig {
        minSdk 21
        targetSdk 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'com.google.android.material:material:1.4.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

task dokkaJavadocJar(type: Jar, dependsOn: dokkaJavadoc) {
    archiveClassifier.set("javadoc")
    from dokkaJavadoc.outputDirectory
}

publishing {
    publications {
        release(MavenPublication) {
            groupId = "com.dokkatests.testlib"
            artifactId = "lib"
            version = "2.1-dataDoc"

            artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
            artifact(dokkaJavadocJar)
        }
    }
}

the generated library javadoc is correctly displayed for methods, but not for the data class level

Documentation correctly displayed for method

Documentation not correctly displayed for class

Note: The html documentation is complete, the issue is only for the documentation displayed in Android Studio. I didn't find any other reference to this issue, which is strange because it looks like a blocker to me. Any clue?

poilu933
  • 61
  • 8

1 Answers1

0

Move KDoc comments of property of data class to be at class level and use @property or @param

example

enter image description here

Mahmoud Mabrok
  • 1,362
  • 16
  • 24
  • Thanks for answering. On my machine, this does not change the issue: after releasing the project as library (using `gradlew mylib:assembleRelease mylib:publishToMavenLocal` for example) and importing the lib in another project, the released lib does not display any documentation in IDE. You can have a look at my issue in github: https://github.com/Kotlin/dokka/issues/2297 – poilu933 Mar 04 '22 at 16:02