5

I was wondering if there is a possibility to include the value of a static field of a class into the documentation of a class method.

We can link class members and parameters via square brackets:

/**
 * 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
}

Goal

But I would like to have the value of MAX_TITLE_LENGTH in the method documentation and not a link to its name.

For the sake of completeness here is my class definition:

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
    }
}

Thanks in advance.

Trickzter
  • 471
  • 3
  • 14

1 Answers1

0

There is nothing like this, because KDoc is based on markup language. Instead of this, using brackets allows you to link between properties of class. See more here: https://kotlinlang.org/docs/reference/kotlin-doc.html#inline-markup

mregulski
  • 160
  • 2
  • 8
  • Yea but it is also based on JavaDoc's syntax as you can see here: https://kotlinlang.org/docs/reference/kotlin-doc.html At https://stackoverflow.com/questions/11426959/javadoc-displaying-value-on-an-inner-class-constant-using-value is an example using the '@value' annotation, but the docs says kotlin doesn't support this. So I thought there may be another way to achieve what '@value' does. – Trickzter Aug 07 '19 at 08:15
  • 1
    Without html postprocessing I do not thing this is possible right now. – mregulski Aug 07 '19 at 11:09