我正在尝试在Android项目中生成KDoc文档。以下是添加此功能的相关文件。build.gradle(根级别):

buildscript {
    ...
    ext.dokka_version = "0.10.1"
    repositories {
        ...
        maven { url "https://dl.bintray.com/kotlin/kotlin-eap/" }
    }
    dependencies {
        ...
        classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
    }
}
...
build.gradle(Module:App)
...
apply plugin: 'org.jetbrains.dokka'

...

dokka {
    outputFormat = 'html' // use 'javadoc' to get standard java docs
    outputDirectory = "$buildDir/javadoc"

    configuration {
        includeNonPublic = false
        skipEmptyPackages = true
        skipDeprecated = true
        reportUndocumented = true
        jdkVersion = 8
    }
}
稍后,我从命令行运行./gradlew dokka。但是没有产生任何输出。以下是我得到的:
> Task :app:dokka
logging: loading modules: [java.se, jdk.accessibility, jdk.attach, jdk.compiler, jdk.dynalink, jdk.httpserver, jdk.jartool, jdk.javadoc, jdk.jconsole, jdk.jdi, jdk.jfr, jdk.jshell, jdk.jsobject, jdk.management, jdk.management.jfr, jdk.net, jdk.scripting.nashorn, jdk.sctp, jdk.security.auth, jdk.security.jgss, jdk.unsupported, jdk.unsupported.desktop, jdk.xml.dom, java.base, java.compiler, java.datatransfer, java.desktop, java.xml, java.instrument, java.logging, java.management, java.management.rmi, java.rmi, java.naming, java.net.http, java.prefs, java.scripting, java.security.jgss, java.security.sasl, java.sql, java.transaction.xa, java.sql.rowset, java.xml.crypto, jdk.internal.jvmstat, jdk.management.agent, jdk.jdwp.agent, jdk.internal.ed, jdk.internal.le, jdk.internal.opt]
No documentation for io.elektrifi.outageplanner.GettingStartedActivity (GettingStartedActivity.kt:9)
No documentation for io.elektrifi.outageplanner.GettingStartedActivity$<init>() (GettingStartedActivity.kt:9)
No documentation for io.elektrifi.outageplanner.GettingStartedActivity$onCreate(android.os.Bundle) (GettingStartedActivity.kt:10)
No documentation for io.elektrifi.outageplanner.LoginActivity (LoginActivity.kt:6)
No documentation for io.elektrifi.outageplanner.LoginActivity$<init>() (LoginActivity.kt:6)
No documentation for io.elektrifi.outageplanner.LoginActivity$onCreate(android.os.Bundle) (LoginActivity.kt:7)
No documentation for io.elektrifi.outageplanner.MainActivity (MainActivity.kt:17)
No documentation for io.elektrifi.outageplanner.MainActivity$<init>() (MainActivity.kt:17)
No documentation for io.elektrifi.outageplanner.MainActivity$onCreate(android.os.Bundle) (MainActivity.kt:18)
No documentation for io.elektrifi.outageplanner.RegisterActivity (RegisterActivity.kt:6)
No documentation for io.elektrifi.outageplanner.RegisterActivity$<init>() (RegisterActivity.kt:6)
No documentation for io.elektrifi.outageplanner.RegisterActivity$onCreate(android.os.Bundle) (RegisterActivity.kt:7)
No documentation for io.elektrifi.outageplanner.SplashScreenActivity (SplashScreenActivity.kt:16)
No documentation for io.elektrifi.outageplanner.SplashScreenActivity$<init>() (SplashScreenActivity.kt:16)
No documentation for io.elektrifi.outageplanner.SplashScreenActivity$onCreate(android.os.Bundle) (SplashScreenActivity.kt:19)

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.1.1/userguide/command_line_interface.html#sec:command_line_warnings
实际上,MainActivity中有一个小的演示脚本。我不确定为什么什么都没有产生。请让我知道我的配置是否正确。同样,拥有一个有效的配置也将很棒。

最佳答案

我是新手,所以我没有意识到。以上配置有效。 KDoc注释必须位于我们要记录的类或函数之上。我在Kotlin文件的最顶部(导入和打包之前)以/**开始注释,以*/结尾,但是它没有用。

关于android - 无法使用Dokka生成Kdoc,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/62997727/

10-12 06:08