文档模板生成 kotlin

Document template generation kotlin

之前在 Android Studio 中工作 如果我在函数之前输入 /** 并按回车键,那么我会自动生成下一个带有注释的文档,用于描述参数、return 值等.

/**
* @params a
* @return
*/
int f(int a)
{
    return a;
}

当我开始在 Android Studio 中使用 Kotlin 时,我尝试生成一个类似的模板,它生成没有 returns、参数等的空白模板

   /**
    *
    */
    fun f(a: Int)
    {
       return a
    }

我安装了 Dokka 并尝试在 Android Stuio 中进行设置,但没有成功。如何在 Android Studio 中为 Kotlin 配置类似模板的生成?

Kotlin,尤其是 KDoc encourage a different documentation style. As stated in this discussion:

The reason is that we found that referring to parameter names from the documentation text allows to write documentation that is more concise and easier to read compared to the traditional javadoc style where every parameter is documented in a separate tag. Therefore, we do not generate the template with parameter names by default. (D. Jemerov, Kotlin in Action Author)

这里有一个 let 的例子,它是标准库的一部分:

/**
 * Calls the specified function [block] with `this` value as its argument and returns its result.
 */
@kotlin.internal.InlineOnly
public inline fun <T, R> T.let(block: (T) -> R): R