如何在 intellij idea/gradle 项目中使用 Java `package-info.java` 记录 Kotlin 包?

Tra*_*ell 5 intellij-idea gradle kotlin kdoc

Kotlinlang.org 说,一个单独的Markdown文件记录了所有包。在 intellij 创意项目中,该 Markdown 文件是否有规范路径?有没有一种规范的方法来使用 gradle 处理该文件?有没有办法将这些 .md 文件与包目录中的 .kt 文件放在一起?

Mah*_*zad 0

如果您想使用Dokka生成文档,您可以创建一个包含.md每个包的标头的单个 markdown () 文件(或者可能是每个包中单独的 markdown 文件,并在该包的文件中包含一个标头):

我的包文档.md:

# Package com.example.mylibrary.firstpackage

This is the docs for firstpackage.

# Package com.example.mylibrary.anotherpackage

This is the docs for anotherpackage.

## This is a subheader for anotherpackages docs
Run Code Online (Sandbox Code Playgroud)

通过使用命令行参数或 Ant、Maven 和Gradle 插件-include中的相应参数将文件路径传递给 Dokka,将 Markdown 文件包含在 Dokka 结果文档中。

以下是我的库build.gradle.kts文件 ( Kotlin DSL )中 Dokka 的示例配置:

# Package com.example.mylibrary.firstpackage

This is the docs for firstpackage.

# Package com.example.mylibrary.anotherpackage

This is the docs for anotherpackage.

## This is a subheader for anotherpackages docs
Run Code Online (Sandbox Code Playgroud)

请参阅Kotlin 文档以获取更多信息。