Skip to content

Commit e8cc53b

Browse files
adam-enkoSpace Team
authored and
Space Team
committed
[Gradle] Document KotlinJsTargetDsl
Expand kdoc for `passAsArgumentToMainFunction()`, `ExperimentalMainFunctionArgumentsDsl` ^KT-76299
1 parent 069cd2e commit e8cc53b

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/dsl/ExperimentalMainFunctionArgumentsDsl.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@
55

66
package org.jetbrains.kotlin.gradle.targets.js.dsl
77

8-
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
9-
@Target(AnnotationTarget.FUNCTION)
8+
import kotlin.RequiresOptIn.Level.WARNING
9+
import kotlin.annotation.AnnotationTarget.FUNCTION
10+
11+
/**
12+
* API marker for defining the source of arguments for the main function.
13+
*
14+
* Passing arguments to the main function is Experimental.
15+
* It may be dropped or changed at any time.
16+
*
17+
* See https://kotl.in/kotlin-js-pass-arguments-to-main-function
18+
*
19+
* @see KotlinJsTargetDsl.passAsArgumentToMainFunction
20+
* @see KotlinJsNodeDsl.passProcessArgvToMainFunction
21+
*/
22+
@RequiresOptIn(level = WARNING)
23+
@Target(FUNCTION)
1024
annotation class ExperimentalMainFunctionArgumentsDsl

libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/dsl/KotlinJsTargetDsl.kt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,20 @@ interface KotlinJsTargetDsl :
164164
fun useEsModules()
165165

166166
/**
167-
* The function accepts [jsExpression] and puts this expression as the "args: Array<String>" argument in place of main-function call
167+
* _This option is only relevant for JS targets._
168+
* _Do not use in WasmJS targets._
169+
*
170+
* > Note: Passing arguments to the main function is Experimental.
171+
* > It may be dropped or changed at any time.
172+
*
173+
* Specify a source of arguments for the `main()` function.
174+
*
175+
* [jsExpression] must be a JavaScript function that returns an array of Strings.
176+
* The array will be set as in the application's main argument, `args: Array<String>`, in place of main-function call.
177+
*
178+
* See https://kotl.in/kotlin-js-pass-arguments-to-main-function
179+
*
180+
* @see KotlinJsNodeDsl.passProcessArgvToMainFunction
168181
*/
169182
@ExperimentalMainFunctionArgumentsDsl
170183
fun passAsArgumentToMainFunction(jsExpression: String)
@@ -244,6 +257,19 @@ interface KotlinJsBrowserDsl : KotlinJsSubTargetDsl {
244257
interface KotlinJsNodeDsl : KotlinJsSubTargetDsl {
245258
fun runTask(body: Action<NodeJsExec>)
246259

260+
/**
261+
* _This option is only relevant for JS targets._
262+
* _Do not use in WasmJS targets._
263+
*
264+
* > Note: Passing arguments to the main function is Experimental.
265+
* > It may be dropped or changed at any time.
266+
*
267+
* Enable passing `process.argv` to the main function's `args` parameter.
268+
*
269+
* See https://kotl.in/kotlin-js-pass-arguments-to-main-function
270+
*
271+
* @see KotlinJsTargetDsl.passAsArgumentToMainFunction
272+
*/
247273
@ExperimentalMainFunctionArgumentsDsl
248274
fun passProcessArgvToMainFunction()
249275
}

0 commit comments

Comments
 (0)