KDoc으로 Kotlin 코드 문서화 (feat. Dokka)

Yowon Jeong ·2024년 7월 15일
1

KDoc

KDoc은 Kotlin 코드의 문서화를 위한 언어로 JavaDoc과 유사합니다.
가장 큰 차이점은 JavaDoc은 HTML을 사용하고 KDoc은 마크다운을 사용한다는 점입니다.

/**
 * A group of *members*.
 *
 * This class has no useful logic; it's just a documentation example.
 *
 * @param T the type of a member in this group.
 * @property name the name of this group.
 * @constructor Creates an empty group.
 */
class Group<T>(val name: String) {
    /**
     * Adds a [member] to this group.
     * @return the new size of the group.
     */
    fun add(member: T): Int { ... }
}
  • JavaDoc과 동일하게 /** 로 시작하여 */로 끝납니다.
  • 문서의 첫번째 단락은 요약이고 두번째 단락부터는 자세한 설명입니다.
  • 모든 블록태그는 줄의 앞부분에 위치하고 @로 시작합니다.
  • 인텔리제이 유용한 플러그인
    kdoc-generator : /** 엔터 누르면 자동 생성

Kotlin 코드를 Dokka로 문서화

  1. build.gradle.kts 에 Dokka plugin 추가
plugins {
    id("org.jetbrains.dokka") version "1.9.20"
}
  1. 자신이 원하는 타입으로 generate
./gradlew dokkaHtml

참고문서

https://github.com/Kotlin/dokka

profile
내가 개발자라니

0개의 댓글