1

I'm tried to annotate like @property but it is not right. Dokka does not recognise it

For example enum:

enum class Vegetables(val id: Int) {
    POTATO(1),
    CARROT(2),
    CUCUMBER(3)
}
  • Not sure which part you're asking about here. What part of the code exactly do you want to document? – Joffrey Aug 24 '21 at 10:42

1 Answers1

1

You can take a look at the Kotlin documentation about how to put doc comments in the code.

You can place documentation wherever the thing you want to document is.

/**
 * Here goes your main Vegetables type doc.
 *
 * You can refer to the [id] constructor argument like this.
 */
enum class Vegetables(
    /**
     * Here goes the doc for your id constructor argument and property.
     */
    val id: Int
) {
    /**
     * Here goes the doc for POTATO.
     */
    POTATO(1),
    /**
     * Here goes the doc for CARROT.
     */
    CARROT(2),
    /**
     * Here goes the doc for CUCUMBER.
     */
    CUCUMBER(3)
}

Alternatively, you can also document properties from the class doc:

/**
 * Here goes your main Vegetables type doc.
 *
 * You can refer to the [id] constructor argument like this.
 *
 * @property id You can also document the id property this way
 */
enum class Vegetables(val id: Int) {
    // ...
}
Joffrey
  • 32,348
  • 6
  • 68
  • 100