我想知道是否有可能将类的静态字段的值包含到类方法的文档中。
我们可以通过方括号链接类成员和参数:
/**
* Sets the title of the notification dialog using [title]
*
* The maximum title length allowed is [MAX_TITLE_LENGTH]
*/
fun setTitle(title: String): NotificationDialog.Builder {
if(title.length <= MAX_TITLE_LENGTH)
mTitle = title
else
mTitle = title.substring(0, MAX_TITLE_LENGTH)
return this
}
目标
但我想MAX_TITLE_LENGTH
在方法文档中有值,而不是指向其名称的链接。
为了完整起见,这是我的类定义:
class Builder(val context: Context) {
private var mTitle = ""
/**
* Sets the title of the notification dialog using [title]
*
* The maximum title length allowed is [MAX_TITLE_LENGTH]
*/
fun setTitle(title: String): NotificationDialog.Builder {
if(title.length <= MAX_TITLE_LENGTH)
mTitle = title
else
mTitle = title.substring(0, MAX_TITLE_LENGTH)
return this
}
fun build(): NotificationDialog {
return NotificationDialog(context, mTitle)
}
companion object {
private const val MAX_TITLE_LENGTH = 20
}
}
提前致谢。