简体   繁体   English

如何在 IntelliJ IDEA/Gradle 项目中使用 Java `package-info.java` 记录 Kotlin 包?

[英]How do I document a Kotlin package like with the Java `package-info.java` in an IntelliJ IDEA/Gradle project?

kotlinlang.org says that a separate markdown file documents all packages. kotlinlang.org 说一个单独的 markdown 文件记录了所有的包。 Is there a canonical path for that markdown file in an IntelliJ IDEA project? IntelliJ IDEA 项目中是否有该降价文件的规范路径? Is there a canonical way to process that file with Gradle?有没有一种规范的方法来使用 Gradle 处理该文件? Is there a way to have these .md files alongside .kt files in the package directory?有没有办法将这些 .md 文件与 .kt 文件放在包目录中?

If you want to produce your documentations using Dokka , you can create a single markdown ( .md ) file with headers for each package (or probably separate markdown file in each package with a single header in that file for that package):如果您想使用Dokka生成您的文档,您可以为每个包创建一个带有标头的单个 markdown ( .md ) 文件(或者可能在每个包中使用单独的 markdown 文件,在该文件中为该包创建一个标头):

my-packages-docs.md:我的包-docs.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

Include the markdown file in the Dokka result docs by passing the path of the file(s) to Dokka using the -include command line parameter or the corresponding parameters in Ant, Maven and Gradle plugin s.通过使用-include命令行参数或 Ant、Maven 和Gradle 插件中的相应参数将文件的路径传递给 Dokka,将 Markdown 文件包含在 Dokka 结果文档中。

Here is an example configuration for Dokka in my library build.gradle.kts file ( Kotlin DSL ):这是我的库build.gradle.kts文件 ( Kotlin DSL ) 中 Dokka 的示例配置:

tasks.dokkaHtml.configure {
    dokkaSourceSets {
        configureEach { // OR named("main") {
            includes.from("my-packages-docs.md", "another.md")
            ...
        }
    }
}

Refer to Kotlin documentations for more information.有关更多信息,请参阅Kotlin 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM