Skip to content

Commit

Permalink
Adds documentation and Dokka plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilhE committed Jul 9, 2024
1 parent 4c63e81 commit e6baf81
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 8 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.gradle.publish) apply false
alias(libs.plugins.kotlin.dokka)
}

buildscript {
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ksp = "2.0.20-Beta1-1.0.22"
kotlinCompose = "1.7.0-alpha01"
kotlinxSerialization = "1.7.1"
kotlinxSerializationPlugin = "2.0.0"
dokka = "1.9.20"
gradlePublish = "1.2.1"
junitImpl = "5.7.2"
junitRuntime = "5.7.2"
Expand All @@ -13,6 +14,7 @@ compileTesting = "1.6.0"
[plugins]
gradle-publish = { id = "com.gradle.plugin-publish", version.ref = "gradlePublish" }
google-ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
kotlin-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin-compose = { id = "org.jetbrains.compose", version.ref = "kotlinCompose" }
Expand Down
1 change: 1 addition & 0 deletions kmp-composeuiviewcontroller-annotations/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
plugins {
`kmp-composeuiviewcontroller-publish`
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.kotlin.dokka)
}

kotlin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ package com.github.guilhe.kmp.composeuiviewcontroller
import kotlin.experimental.ExperimentalObjCRefinement
import kotlin.native.HidesFromObjC

/**
* Used to annotate the @Composable as a desired ComposeUIViewController to be used by the iOS app. While the plugin typically attempts to retrieve this name automatically, you can use this parameter to enforce a specific name if the automatic retrieval fails.
* [More here](https://github.com/GuilhE/KMP-ComposeUIViewController?tab=readme-ov-file#kmp-module)
* @param frameworkBaseName Kotlin Multiplatform library iOS targets framework base name
*/
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.BINARY)
@OptIn(ExperimentalObjCRefinement::class)
@HidesFromObjC
/**
* @param frameworkBaseName: shared library framework's base name
*/
public annotation class ComposeUIViewController(val frameworkBaseName: String = "")

/**
* Used to annotate the parameter as the composable state variable (for advanced use cases). Only 0 or 1 [ComposeUIViewControllerState] and an arbitrary number of parameter types (excluding [Composable] functions) are allowed in [ComposeUIViewController] functions.
* [More here](https://github.com/GuilhE/KMP-ComposeUIViewController?tab=readme-ov-file#kmp-module)
*/
@Target(AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION)
@Retention(AnnotationRetention.SOURCE)
public annotation class ComposeUIViewControllerState
1 change: 1 addition & 0 deletions kmp-composeuiviewcontroller-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.gradle.publish)
alias(libs.plugins.kotlinx.serialization)
alias(libs.plugins.kotlin.dokka)
}

kotlin {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package com.github.guilhe.kmp.composeuiviewcontroller.gradle

/**
* Gradle extension to configure the plugin parameters
* @property iosAppFolderName Name of the folder containing the iosApp in the root's project tree
* @property iosAppName Name of the iOS project (name.xcodeproj)
* @property targetName Name of the iOS project's target
* @property exportFolderName Name of the destination folder inside iOS project ([iosAppFolderName]) where the Composable files will be copied to when [autoExport] is `true`
* @property autoExport Enables auto export generated files to Xcode project. If set to false, you will find the generated files under / build/ generated/ ksp/. Warning: avoid deleting [iosAppFolderName]/[exportFolderName] without first using Xcode to Remove references.
*/
public open class ComposeUiViewControllerParameters {
/**
* Name of the folder containing the iosApp in the root's project tree
Expand All @@ -22,10 +30,7 @@ public open class ComposeUiViewControllerParameters {
public var exportFolderName: String = "Representables"

/**
* Auto export generated files to Xcode project
*
* If set to `false`, you will find the generated files under `/build/generated/ksp/`.
* Warning: avoid deleting `[iosAppFolderName]/[exportFolderName]` without first using Xcode to Remove references.
* Auto export generated files to Xcode project. If set to `false`, you will find the generated files under `/build/generated/ksp/`. Warning: avoid deleting `[iosAppFolderName]/[exportFolderName]` without first using Xcode to Remove references.
*/
public var autoExport: Boolean = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import org.jetbrains.kotlin.konan.target.Family
import java.io.BufferedReader
import java.io.File

/**
* Heavy lifts gradle configurations when using [KMP-ComposeUIViewController](https://github.com/GuilhE/KMP-ComposeUIViewController) library.
*/
public class KmpComposeUIViewControllerPlugin : Plugin<Project> {

private fun KotlinTarget.fromIosFamily(): Boolean = this is KotlinNativeTarget && konanTarget.family == Family.IOS
Expand Down Expand Up @@ -138,7 +141,7 @@ public class KmpComposeUIViewControllerPlugin : Plugin<Project> {
} catch (e: Exception) {
mutableSetOf()
}
args.forEach { (key, value) -> moduleMetadata.add(ModuleMetadata(name = name.toString(), packageNames = value, frameworkBaseName = key)) }
args.forEach { (key, value) -> moduleMetadata.add(ModuleMetadata(name = name, packageNames = value, frameworkBaseName = key)) }
file.writeText(Json.encodeToString(moduleMetadata))
}

Expand Down

0 comments on commit e6baf81

Please sign in to comment.