KDoc Annotations not rendered in Dokka generated HTML

孤人 提交于 2020-04-13 18:37:06

问题


I am currently testing the Dokka documentation and some of the annotations I have made are not being rendered. Here are my findings:

  1. Classes don't show @sample, and html tags <p></p>, <h1></h1>: See SimpleCalculator class documentation
  2. If a description was under an html tag, it will not show: See enum class OPERATOR code documentation
  3. Methods don't show @sample and @property at all: See all the method code documentation
  4. Mixed of definition between @property and @param. In class declarations, the @param is the one inside a <> (e.g. Group<T>). But in methods, it is the one inside the parameters.

Please see my code:

package example

/**
 * <h1> A Simple Calculator for your daily needs! </h1>
 *
 * <p> This class can help you add, subract, multiply and divide Integers </p>
 *
 * @property firstNumber the first Number you want to use
 * @property secondNumber the second Number you want to use.
 * @constructor Creates a Simple Calculator with the two numbers
 * @sample SimpleCalculator(100,10)
 */
class SimpleCalculator(val firstNumber: Int, val secondNumber: Int) {

    /**
     * <h1> An OPERATOR checker to be used by the Simple Calculator </h1>
     *
     * <p> This class has four enums namely: </p>
     * - ADD
     * - SUB
     * - MUL
     * - DIV
     * @see SimpleCalculator
     */
    enum class OPERATOR { ADD, SUB, MUL, DIV }

    /**
     * Computes with the [firstNumber] and [secondNumber] you have created with [SimpleCalculator].
     * @param operator the required OPERATOR needed for the computation
     * @sample compute(OPERATOR.ADD)
     * @see SimpleCalculator
     * @return the required answer
     */
    fun compute(operator: OPERATOR): Int {
        return when (operator) {
            OPERATOR.ADD -> add(firstNumber, secondNumber)
            OPERATOR.SUB -> sub(firstNumber, secondNumber)
            OPERATOR.MUL -> mul(firstNumber, secondNumber)
            OPERATOR.DIV -> div(firstNumber, secondNumber)
        }
    }

    /**
     * Adds the [firstNumber] and [secondNumber] you have created with [SimpleCalculator].
     * @property firstNumber the first number
     * @property secondNumber the first number
     * @sample add(100, 10)
     * @see SimpleCalculator
     * @return the sum
     * @throws Exception
     */
    fun add(firstNumber: Int, secondNumber: Int): Int = firstNumber + secondNumber

    /**
     * Subtracts the [firstNumber] and [secondNumber] you have created with [SimpleCalculator].
     * Returns the differences
     * @param firstNumber the first number
     * @param secondNumber the second number
     * @sample sub(100, 10)
     * @see SimpleCalculator
     * @return the difference
     * @throws Exception
     */
    fun sub(firstNumber: Int, secondNumber: Int): Int = firstNumber - secondNumber

    /**
     * Multiplies the [firstNumber] and [secondNumber] you have created with [SimpleCalculator].
     * Using [add] as a multiplication factor
     * @sample mul(100, 10)
     * @see add
     * @return the product
     * @throws Exception
     */
    fun mul(firstNumber: Int, secondNumber: Int): Int {
        var result = firstNumber
        var i = 2
        while (i < secondNumber && secondNumber != 0) {
            result += add(result, firstNumber)
            i++
        }

        return result
    }

    /**
     * Divides the [firstNumber] and [secondNumber] you have created with [SimpleCalculator].
     * Using [sub] as a division factor
     * @sample div(100, 10)
     * @see sub
     * @return the dividend
     * @throws Exception
     */
    fun div(firstNumber: Int, secondNumber: Int): Int {
        var result = firstNumber
        var i = 2
        while (i < secondNumber && secondNumber != 0) {
            result -= sub(result, firstNumber)
            i++
        }

        return result
    }

}

my top Build file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.2.0'
    ext.dokka_version = '0.9.15'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.dokka:dokka-gradle-plugin:${dokka_version}"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

My project build file:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'org.jetbrains.dokka'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.hellodokka"
        minSdkVersion 18
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dokka {
    outputFormat = 'html'
    outputDirectory = "$buildDir/html"
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

OUTPUTS:

Can somebody help out?

来源:https://stackoverflow.com/questions/48097572/kdoc-annotations-not-rendered-in-dokka-generated-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!