英文:
Dokka is not generating documentation for test package
问题
我在我的测试代码中有KDoc样式的注释,我想使用Kotlin DSL Gradle dokkaHtml任务生成文档。但在成功执行任务后,它显示**“退出生成:没有要文档化的内容”**。
我已经尝试设置源文件,但没有任何变化。我想要获取测试包中代码的HTML文档。
英文:
I have KDoc style comments in my tests code and I want to generate documentation using Kotlin DSL Gradle dokkaHtml tasks. But after successfully executing the task it says "Exiting Generation: Nothing to document".
I have tried to set sources but nothing has changed. I want to get the html documentation for code in my test package.
答案1
得分: 0
Dokka 用于文档化库的源代码,提供有关 API 工作方式的发布文档。test
源集应该包含用于测试库代码的单元测试,而不一定要文档化库;这是库本身的工作,即 main
源集的工作。示例函数(https://kotlinlang.org/docs/kotlin-doc.html#sample-identifier)会生成文档。或者,您可以配置 Dokka 将 test
源集视为源代码,而不是测试代码:
tasks.withType<DokkaTask>().configureEach {
dokkaSourceSets {
named("test") {
sourceRoots.from(file("src/test/"))
}
}
}
另请参阅:https://kotlinlang.org/docs/dokka-gradle.html#source-set-configuration
英文:
Dokka is meant to be used to document source code of libraries, to provide documentation to publish about how your API works. The test
source set is supposed to contain unit tests for testing the library code, and not neccesarily to also document the library; that's the job of the library itself, the main
source set. Sample functions (https://kotlinlang.org/docs/kotlin-doc.html#sample-identifier) would generate documentation, though. Alternatively, you can configure dokka to consider the test
source set as source code, and not testing code:
tasks.withType<DokkaTask>().configureEach {
dokkaSourceSets {
named("test") {
sourceRoots.from(file("src/test/"))
}
}
}
See also: https://kotlinlang.org/docs/dokka-gradle.html#source-set-configuration
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论