【问题标题】:How to configure Dokka for package documentation using Gradle?如何使用 Gradle 为包文档配置 Dokka?
【发布时间】:2020-04-06 00:25:29
【问题描述】:

如果不使用来自文件系统根目录的完整绝对路径,我无法将 Dokka 配置为包含我的包的文档。我的 Gradle 文件中有(includes 行有问题):

dokka {
    outputFormat = 'html'
    outputDirectory = "$projectDir/../doc"


    configuration {
        // Use to include or exclude non public members.
        includeNonPublic = false

        // Do not output deprecated members. Applies globally, can be overridden by packageOptions
        skipDeprecated = false

        // Emit warnings about not documented members. Applies globally, also can be overridden by packageOptions
        reportUndocumented = true

        // Do not create index pages for empty packages
        skipEmptyPackages = true

        includes = ["${projectDir}/app/src/main/kotlin/com/biexpertise/simplewebview/packages.md"]
    }
}

如果出现此错误,我会运行 ./gradlew dokka

> Task :app:dokka FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:dokka'.
> org.codehaus.groovy.runtime.GStringImpl cannot be cast to java.lang.String

如果我删除 $projectDir 并使用绝对路径,一切正常。可以改用相对路径吗?

【问题讨论】:

    标签: gradle kotlin-dokka


    【解决方案1】:

    所以这实际上是 dokka 的 Gradle 插件的问题,或者更具体地说,是 Groovy String 实现的问题。 Groovy 使用它自己的 GStringImpl 来处理字符串,而不是 String 类,这会导致在将 List<GStringImpl> 转换为 List<String> 时出现问题(此转换不成功)。

    最简单的解决方案是在您的 include 上调用 .toString(),如下所示:

    includes = ["${projectDir}/app/src/main/kotlin/com/biexpertise/simplewebview/packages.md".toString()]
    

    这应该在 dokka 端修复,你可以在 GitHub 上提交错误报告

    【讨论】:

      猜你喜欢
      • 2019-11-17
      • 2020-08-15
      • 2020-02-05
      • 2016-05-29
      • 2019-09-21
      • 1970-01-01
      • 2019-07-01
      • 2020-07-13
      • 2021-07-21
      相关资源
      最近更新 更多