Blog Infos
Author
Published
Topics
,
Published
Topics
,

We all know that “Good code documents itself” but documenting your code won’t hurt anyone’s(especially Vegita’s) pride.

But HOW?

To write documentation for Kotlin code we can use the following plugin:

KDoc-er – Kotlin Doc Generator – IntelliJ IDEs Plugin | Marketplace

With the plugin, we can automatically generate Kdocs like this:

/**
 * Image view show image from url
 *
 * @param imageUrl url of the image
 */

Once we are done with the Kdoc it is time to show off what we have done and we need Dokka for that.

Dokka

We have to add Dokka to our project

1- At the project level Gradle file
dependencies {
    classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.6.0"
}
2- In each module Gradle that we want to document
apply plugin: "org.jetbrains.dokka"
Note:

Make sure that:

1- Your Gradle, android studio and project use java 11 (check by terminal with ./gradlew — version)

2- Dokka plugin must be applied after “com.android.application” and “org.jetbrains.kotlin.android”

After sync and rebuild (to make sure we can invalidate cache as well but it is optional) in terminal we will call one of the following lines:

1- ./gradlew dokkaHtml dokkaHtmlMultiModule (for multi module)

2- ./gradlew dokkaHtml dokkaHtml (for single module)

Once Dokka is done you can open index.html from the browser and well-written documentation is in front of you.

References and More

1- Raywanderlich

2- Ahmetburakilhan’s article

3- Dokka

With Special Thanks To

This article was originally published on proandroiddev.com on July 02, 2022

Job Offers

Job Offers


    Mobile Engineer

    OLX Group
    Remote, Portugal, Spain, Romania, Poland
    • Full Time
    apply now

    Android Software Engineer (f/m/d)

    Paradox Cat GmbH
    Munich
    • Full Time
    apply now

    Senior Android Software Engineer (f/m/d)

    Paradox Cat GmbH
    Munich
    • Full Time
    apply now

OUR VIDEO RECOMMENDATION

,

At long last we have Kotlin first at Meta!

Android started to support Kotlin 5 years ago and became the first-choice language three years ago. But Meta just announced Kotlin as the preferred and default language for our Android code base only 3 months…
Watch Video

At long last we have Kotlin first at Meta!

Peng Jiang & Sergei Rybalkin
Software Engineer & Kotlin
Meta

At long last we have Kotlin first at Meta!

Peng Jiang & Serge ...
Software Engineer & ...
Meta

At long last we have Kotlin first at Meta!

Peng Jiang & Ser ...
Software Engineer & Kotli ...
Meta

Jobs

YOU MAY BE INTERESTED IN

YOU MAY BE INTERESTED IN

blog
It’s one of the common UX across apps to provide swipe to dismiss so…
READ MORE
blog
Hi, today I come to you with a quick tip on how to update…
READ MORE
blog
Automation is a key point of Software Testing once it make possible to reproduce…
READ MORE
blog
Drag and Drop reordering in Recyclerview can be achieved with ItemTouchHelper (checkout implementation reference).…
READ MORE

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

Menu