From 30215fe880b090a1e2fea52fb475027791bb1fde Mon Sep 17 00:00:00 2001 From: tonisives Date: Fri, 1 Dec 2023 07:35:47 +0700 Subject: [PATCH] add kdoc and javadoc --- .github/workflows/create-docs.yml | 8 +++++--- hmkit-fleet/build.gradle | 8 ++++++++ .../hmkitfleet/HMKitConfiguration.kt | 10 ++++++++++ .../highmobility/hmkitfleet/HMKitCredentials.kt | 17 +++++++++++++++++ .../com/highmobility/hmkitfleet/HMKitFleet.kt | 5 +++++ .../highmobility/hmkitfleet/utils/CallAwait.kt | 2 +- 6 files changed, 46 insertions(+), 4 deletions(-) diff --git a/.github/workflows/create-docs.yml b/.github/workflows/create-docs.yml index 44c9705..3eb2fc9 100644 --- a/.github/workflows/create-docs.yml +++ b/.github/workflows/create-docs.yml @@ -8,6 +8,7 @@ on: branches: - main - v2 + - dokka jobs: docs: @@ -22,7 +23,6 @@ jobs: java-version: 17 cache: gradle - - name: Setup SSH Keys and known_hosts to access submodules env: SSH_AUTH_SOCK: /tmp/ssh_agent.sock @@ -36,11 +36,13 @@ jobs: run: git submodule update --init --recursive - name: Create docs - run: ./gradlew :hmkit-fleet:dokkaJavadoc + run: | + ./gradlew :hmkit-fleet:dokkaJavadoc + ./gradlew :hmkit-fleet:dokkaHtml - name: Deploy to Github Pages uses: JamesIves/github-pages-deploy-action@v4 with: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} BRANCH: gh-pages - FOLDER: hmkit-fleet/build/dokka/javadoc \ No newline at end of file + FOLDER: hmkit-fleet/build/dokka/html \ No newline at end of file diff --git a/hmkit-fleet/build.gradle b/hmkit-fleet/build.gradle index 8fa58e0..faa3be9 100644 --- a/hmkit-fleet/build.gradle +++ b/hmkit-fleet/build.gradle @@ -58,4 +58,12 @@ dependencies { detekt { config = files("$rootDir/detekt.yaml") buildUponDefaultConfig = true +} + +dokkaHtml { + outputDirectory.set(file("$buildDir/dokka/html/v2")) +} + +dokkaJavadoc { + outputDirectory.set(file("$buildDir/dokka/html/v2/javadoc")) } \ No newline at end of file diff --git a/hmkit-fleet/src/main/kotlin/com/highmobility/hmkitfleet/HMKitConfiguration.kt b/hmkit-fleet/src/main/kotlin/com/highmobility/hmkitfleet/HMKitConfiguration.kt index 2d0fe89..6be114b 100644 --- a/hmkit-fleet/src/main/kotlin/com/highmobility/hmkitfleet/HMKitConfiguration.kt +++ b/hmkit-fleet/src/main/kotlin/com/highmobility/hmkitfleet/HMKitConfiguration.kt @@ -2,6 +2,16 @@ package com.highmobility.hmkitfleet import okhttp3.OkHttpClient +/** + * The configuration for the SDK. This is a mandatory class to be passed to the SDK. + * + * @param credentials The credentials to be used for the SDK. Choose from either [HMKitOAuthCredentials] or + * [HMKitPrivateKeyCredentials]. + * @param environment The SDK environment. Default is Production. + * @param client Optionally, set the OkHttpClient to be used for network requests. + * + * [javadoc](https://highmobility.github.io/hmkit-fleet-v2/v2/javadoc/com/highmobility/hmkitfleet/HMKitConfiguration.html) + */ class HMKitConfiguration private constructor(builder: Builder) { val credentials = builder.credentials ?: throw IllegalArgumentException("credentials must be set") val client = builder.client ?: OkHttpClient() diff --git a/hmkit-fleet/src/main/kotlin/com/highmobility/hmkitfleet/HMKitCredentials.kt b/hmkit-fleet/src/main/kotlin/com/highmobility/hmkitfleet/HMKitCredentials.kt index c311e63..034e0aa 100644 --- a/hmkit-fleet/src/main/kotlin/com/highmobility/hmkitfleet/HMKitCredentials.kt +++ b/hmkit-fleet/src/main/kotlin/com/highmobility/hmkitfleet/HMKitCredentials.kt @@ -9,6 +9,13 @@ import java.security.interfaces.ECPrivateKey import java.security.spec.PKCS8EncodedKeySpec import java.util.Base64 +/** + * The credentials to be used for the SDK. Choose from either [HMKitOAuthCredentials] or + * [HMKitPrivateKeyCredentials]. + * + * [javadoc](https://highmobility.github.io/hmkit-fleet-v2/v2/javadoc/com/highmobility/hmkitfleet/HMKitCredentials.html) + * + */ abstract class HMKitCredentials { internal abstract fun getTokenRequestBody(jwtProvider: JwtProvider?): String @@ -19,6 +26,11 @@ abstract class HMKitCredentials { } } +/** + * The OAuth credentials to be used for the SDK. + * + * [javadoc](https://highmobility.github.io/hmkit-fleet-v2/v2/javadoc/com/highmobility/hmkitfleet/HMKitOAuthCredentials.html) + */ @Serializable data class HMKitOAuthCredentials( /** @@ -42,6 +54,11 @@ data class HMKitOAuthCredentials( } } +/** + * The private key credentials to be used for the SDK. + * + * [javadoc](https://highmobility.github.io/hmkit-fleet-v2/v2/javadoc/com/highmobility/hmkitfleet/HMKitPrivateKeyCredentials.html) + */ @Serializable data class HMKitPrivateKeyCredentials( /** diff --git a/hmkit-fleet/src/main/kotlin/com/highmobility/hmkitfleet/HMKitFleet.kt b/hmkit-fleet/src/main/kotlin/com/highmobility/hmkitfleet/HMKitFleet.kt index 2942d6a..3d0a665 100644 --- a/hmkit-fleet/src/main/kotlin/com/highmobility/hmkitfleet/HMKitFleet.kt +++ b/hmkit-fleet/src/main/kotlin/com/highmobility/hmkitfleet/HMKitFleet.kt @@ -48,6 +48,9 @@ import java.util.concurrent.CompletableFuture * .build() * ); * ``` + * + * [javadoc](https://highmobility.github.io/hmkit-fleet-v2/v2/javadoc/com/highmobility/hmkitfleet/HMKitFleet.html) + * */ class HMKitFleet constructor( /** @@ -140,6 +143,8 @@ class HMKitFleet constructor( /** * The Fleet SDK environment. + * + * [javadoc](https://highmobility.github.io/hmkit-fleet-v2/v2/javadoc/com/highmobility/hmkitfleet/HMKitFleet.Environment.html) */ enum class Environment { PRODUCTION, SANDBOX; diff --git a/hmkit-fleet/src/main/kotlin/com/highmobility/hmkitfleet/utils/CallAwait.kt b/hmkit-fleet/src/main/kotlin/com/highmobility/hmkitfleet/utils/CallAwait.kt index 460b3f6..1b1bfaa 100644 --- a/hmkit-fleet/src/main/kotlin/com/highmobility/hmkitfleet/utils/CallAwait.kt +++ b/hmkit-fleet/src/main/kotlin/com/highmobility/hmkitfleet/utils/CallAwait.kt @@ -9,7 +9,7 @@ import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException @Suppress("TooGenericExceptionCaught", "SwallowedException") -suspend fun Call.await(): Response { +internal suspend fun Call.await(): Response { return suspendCancellableCoroutine { continuation -> enqueue(object : Callback { override fun onResponse(call: Call, response: Response) {