Search code examples
kotlindocumentationkotlin-dokka

Using KDoc to document group of variables


So I have this group of constants in a companion object:

        /**
         * Lists that can be associated to various media elements
         */
        const val MEDIA_NAME = "Media_name"
        const val SONGS_IDS = "Songs_ids"
        const val GENRE_IDS = "Genres_ids"
        const val ARTISTS_IDS = "Artists_ids"

When I execute dokka, the comment associated to the constants doesn't format correctly in the docs... how can I use one description for multiple constants?


Solution

  • You can group elements in kDoc by grouping them in the code:

    /**
     * Lists that can be associated to various media elements
     */
    object Media {
        const val NAME = "Media_name"
        const val SONGS_IDS = "Songs_ids"
        const val GENRE_IDS = "Genres_ids"
        const val ARTISTS_IDS = "Artists_ids"
    }