본문 바로가기

Android

dokka (kdoc)

진행하는 프로젝트에 kotlin 파일이 늘어나다 보니 =_ = 기존의 javadoc 으로는 답 안나와서 kdoc 으로 변경하려고 했는데
 
=_ = multi project 형태는 아직 명확한 답이 없네?? 단일 프로젝트는 단순 명료하지만
다중 프로젝트로 (다수의 라이브러리 모듈) 구성된 형태라면 현재로서는 각각으로 생성되는데 하나로 합쳐지는 형태가
 
딱히 보이질 않는다.
 
내가 못찾는것 일수도 있지만 =_ = 일단 kdoc 적용은 보류
 

 
dokka
 
설명도 간단했다. 

 

Java엔 JavaDoc이 있다면, Kotlin엔 KDoc[1]이 있습니다!
Inline Markup은 Markdown 문법으로 작성할 수 있어서 아주 편리합니다.

 

 

문서를 생성하는 툴은 dokka[2]를 이용합니다.
커멘드라인으로도 할 수 있고, Ant, Gradle을 이용하여 문서 생성을 할 수 있습니다!

 

 

 

 

 
일단 프로젝트에서 이용하기 위해 먼저 gradle 을 변경 해 주어야 했는 데 
 
 
먼저 root level build.gradle 에 dokka 버전과 classpath 를 지정하였고 
buildscript {
    ext {
        dokka_version = '0.10.0'
    }
    dependencies {
        classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
    }
}
app level 또는 library level 의 build.gradle 에 아래와 같이 설정하였다. 
apply pluginorg.jetbrains.dokka'
 
android {
    // ...
}
 
dokka {
    outputFormat = 'html'
    outputDirectory = "$rootDir/javadocs
}
 
이후 파일을 생성하도록 하기 위해서 ./gradlew dokka 를 호출 하였더니 html 파일들이 생성되었다. 
파일 생성시 추가적인 옵션은 https://github.com/Kotlin/dokka/blob/master/README.md 를 참조하면 된다. 
 
kdoc 문법
 
  • @param - method parameter description
  • @return - documents returned value
  • @constructor - documents primary constructor
  • @receiver - receiver for extension functions
  • @property - class property description
  • @throws@exception - describes exceptions thrown by method, no need to put all of them here
  • @sample - link to code sample with documented element used
  • @see - link to another element
  • @author - when you feel especially proud of your code
  • @since - version name where this element was introduced
  • @suppress - excludes element from documentation
 
easy dokka plugin