Kotlin writes doc documents and exports them
In the past, we used java to write interface documents, and after writing, we directly used the functions that come with as to directly export interface documents
This will directly export the interface document at the destination, but when using kotlin to define the interface, an error will be reported if it is used directly:
so we adopt another method
Use the officially recommended dokka plugin
How to use it
First, the access dependency is integrated in the app gradle
buildscript {
...
dependencies {
...
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.7.20")
}
}
plugins {
...
id("org.jetbrains.dokka") version "1.7.20"
}
...
dependencies {
...
dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.7.20")
}
// 配置导出信息
tasks.dokkaJavadoc.configure {
// 导出的文档目录路径
outputDirectory.set(new File(rootDir, "doc"))
// dokkaSourceSets {
// named("main") {
// noAndroidSdkLink.set(true)
// noStdlibLink.set(true)
// noJdkLink.set(true)
// }
// configureEach {
// // 包的定义
// includes.from("packages.md")
// }
// }
}
Just configure it as simple as that, and then directly click the task dokkaJavaDoc under dcumentation in the gradle on the right. After execution, an interface document will be generated in the local root directory of the project. Open the index.html inside to view the interface
document