Dokka没有为测试包生成文档。

huangapple go评论54阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年6月5日 16:32:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76404703.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定