ユーザ用ツール

サイト用ツール


サイドバー

android:androidstudioにkdocをインストール

以前のリビジョンの文書です


Android Studioにkdocをインストール

Kotlin版Javadoc(Kdoc)を生成できる「dokka」の導入手順

kdoc-generator-intellij-plugin

dokkaはKotlin版のJavadoc、つまりKdocを生成するもの。
kdoc-generator-intellij-pluginは、Kdocの入力をサポートするもの。雛形を生成する。

dokkaのインストール

// Top-level build file where you can add configuration options common to all sub-projects/modules.
 
buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
 
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
 
    // ↓追加
    ext.dokka_version = '0.9.17'
 
    repositories {
        jcenter()
    }
 
    dependencies {
        classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:${dokka_version}"
    }
    // ↑追加
}
 
allprojects {
    repositories {
        google()
        jcenter()
 
    }
}
 
task clean(type: Delete) {
    delete rootProject.buildDir
}
apply plugin: 'com.android.application'
 
apply plugin: 'kotlin-android'
 
apply plugin: 'kotlin-android-extensions'
 
apply plugin: 'org.jetbrains.dokka-android' // 追加
 
android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "com.nekotype.ips.locationchecker"
        minSdkVersion 27
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
 
    // ↓ 追加
    dokka {
        outputFormat = 'javadoc'
        sourceDirs = files('src/main')
        outputDirectory = "$buildDir/javadoc"
    }
    // ↑ 追加
}
 
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

Terminalで下記コマンドでKdoc生成。

gradlew dokka

kdoc-generator-intellij-pluginのインストール

Android Studioの
メニュー > File > Settins

Pluginsを選択し、MarketPlaceよりkdoc-generatorを検索してインストールし、Android Stuidoを再起動する。

関数などの上で、「/**」を入力してエンターをすると、Kdocの雛形ができる。

android/androidstudioにkdocをインストール.1571463250.txt.gz · 最終更新: 2019/10/19 14:34 by ips