Skip to content

Commit 322379e

Browse files
committed
Assorted stdlib KDocs
1 parent 1d86bd5 commit 322379e

File tree

13 files changed

+207
-9
lines changed

13 files changed

+207
-9
lines changed

core/reflection.jvm/src/kotlin/reflect/jvm/internal/KotlinReflectionInternalError.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ import kotlin.reflect.KotlinReflectionInternalError
2020

2121
/**
2222
* Signals that Kotlin reflection had reached an inconsistent state from which it cannot recover.
23+
* @suppress
2324
*/
2425
class KotlinReflectionInternalError(message: String) : KotlinReflectionInternalError(message)

js/js.libraries/src/core/core.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ public external val noImpl: Nothing
55

66
public external val definedExternally: Nothing
77

8+
/**
9+
* Exposes the JavaScript [eval function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) to Kotlin.
10+
*/
811
public external fun eval(expr: String): dynamic
912

13+
/**
14+
* Exposes the JavaScript [undefined property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) to Kotlin.
15+
*/
1016
public external val undefined: Nothing?
1117

1218
@Deprecated("Use toInt() instead.", ReplaceWith("s.toInt()"), level = DeprecationLevel.ERROR)

js/js.libraries/src/core/date.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package kotlin.js
22

3+
/**
4+
* Exposes the [Date API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) to Kotlin.
5+
*/
36
public external class Date() {
47
public fun getTime(): Double
58
}

js/js.libraries/src/core/debug.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package kotlin.js
22

3-
// https://developer.mozilla.org/en/DOM/console
3+
/**
4+
* Exposes the [console API](https://developer.mozilla.org/en/DOM/console) to Kotlin.
5+
*/
46
external public interface Console {
57
public fun dir(o: Any): Unit
68
public fun error(vararg o: Any?): Unit
@@ -9,4 +11,7 @@ external public interface Console {
911
public fun warn(vararg o: Any?): Unit
1012
}
1113

14+
/**
15+
* Exposes the [console API](https://developer.mozilla.org/en/DOM/console) to Kotlin.
16+
*/
1217
public external val console: Console

js/js.libraries/src/core/dynamic.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
package kotlin.js
1818

19+
/**
20+
* Reinterprets this value as a value of the [dynamic type](/docs/reference/dynamic-type.html).
21+
*/
1922
@kotlin.internal.InlineOnly
2023
public inline fun Any?.asDynamic(): dynamic = this
2124

js/js.libraries/src/core/json.kt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,52 @@
11
package kotlin.js
22

3+
/**
4+
* An interface for indexing access to a collection of key-value pairs, where type of key is [String] and type of value is [Any?].
5+
*/
36
public external interface Json {
7+
/**
8+
* Calls to the function will be translated to indexing operation (square brackets) on the receiver with [propertyName] as the argument.
9+
*
10+
* E.g. for next code:
11+
* ```kotlin
12+
* fun test(j: Json, p: String) = j["prop"] + j.get(p)
13+
* ```
14+
*
15+
* will be generated:
16+
* ```js
17+
* function test(j, p) {
18+
* return j["prop"] + j[p];
19+
* }
20+
* ```
21+
*/
422
operator fun get(propertyName: String): Any?
23+
24+
/**
25+
* Calls of the function will be translated to an assignment of [value] to the receiver indexed (with square brackets/index operation) with [propertyName].
26+
*
27+
* E.g. for the following code:
28+
* ```kotlin
29+
* fun test(j: Json, p: String, newValue: Any) {
30+
* j["prop"] = 1
31+
* j.set(p, newValue)
32+
* }
33+
* ```
34+
*
35+
* will be generated:
36+
* ```js
37+
* function test(j, p, newValue) {
38+
* j["prop"] = 1;
39+
* j[p] = newValue;
40+
* }
41+
* }
42+
* ```
43+
*/
544
operator fun set(propertyName: String, value: Any?): Unit
645
}
746

47+
/**
48+
* Returns a simple JavaScript object (as [Json]) using provided key-value pairs as names and values of its properties.
49+
*/
850
public fun json(vararg pairs: Pair<String, Any?>): Json {
951
val res: dynamic = js("({})")
1052
for ((name, value) in pairs) {
@@ -13,6 +55,10 @@ public fun json(vararg pairs: Pair<String, Any?>): Json {
1355
return res
1456
}
1557

58+
/**
59+
* Adds key-value pairs from [other] to [this].
60+
* Returns the original receiver.
61+
*/
1662
public fun Json.add(other: Json): Json {
1763
val keys: Array<String> = js("Object").keys(other)
1864
for (key in keys) {
@@ -23,6 +69,9 @@ public fun Json.add(other: Json): Json {
2369
return this
2470
}
2571

72+
/**
73+
* Exposes the JavaScript [JSON object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON) to Kotlin.
74+
*/
2675
public external object JSON {
2776
public fun stringify(o: Any?): String
2877
public fun stringify(o: Any?, replacer: (key: String, value: Any?) -> Any?): String

js/js.libraries/src/core/math.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package kotlin.js
22

33
//TODO: declare using number
4+
/**
5+
* Exposes the JavaScript [Math object](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Math) to Kotlin.
6+
*/
47
public external object Math {
58
public val PI: Double
69
public fun random(): Double
@@ -27,5 +30,12 @@ public external object Math {
2730
public fun ceil(value: Number): Int
2831
}
2932

33+
/**
34+
* Returns the smaller of two values.
35+
*/
3036
public fun Math.min(a: Long, b: Long): Long = if (a <= b) a else b
31-
public fun Math.max(a: Long, b: Long): Long = if (a >= b) a else b
37+
38+
/**
39+
* Returns the greater of two values.
40+
*/
41+
public fun Math.max(a: Long, b: Long): Long = if (a >= b) a else b

js/js.libraries/src/core/promise.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
package kotlin.js
1818

19+
/**
20+
* Exposes the JavaScript [Promise object](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise) to Kotlin.
21+
*/
1922
public open external class Promise<out T>(executor: (resolve: (T) -> Unit, reject: (Throwable) -> Unit) -> Unit) {
2023
companion object {
2124
public fun <S> all(promise: Array<out Promise<S>>): Promise<Array<in S>>

js/js.libraries/src/core/regexp.kt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
package kotlin.js
1818

19-
19+
/**
20+
* Exposes the JavaScript [RegExp object](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/RegExp) to Kotlin.
21+
*/
2022
public external class RegExp(pattern: String, flags: String? = definedExternally) {
2123

2224
public fun test(str: String): Boolean
@@ -35,17 +37,31 @@ public external class RegExp(pattern: String, flags: String? = definedExternally
3537
public val multiline: Boolean
3638
}
3739

40+
/**
41+
* Resets the regular expression so that subsequent [RegExp.test] and [RegExp.exec] calls will match starting with the beginning of the input string.
42+
*/
3843
public fun RegExp.reset() {
3944
lastIndex = 0
4045
}
4146

4247
// TODO: Inherit from array or introduce asArray() extension
48+
/**
49+
* Represents the return value of [RegExp.exec].
50+
*/
4351
public external interface RegExpMatch {
4452
public val index: Int
4553
public val input: String
4654
public val length: Int
4755
}
4856

57+
/**
58+
* Returns the entire text matched by [RegExp.exec] if the [index] parameter is 0, or the text matched by the capturing parenthesis
59+
* at the given index.
60+
*/
4961
public inline operator fun RegExpMatch.get(index: Int): String? = asDynamic()[index]
5062

51-
public inline fun RegExpMatch.asArray(): Array<out String?> = unsafeCast<Array<out String?>>()
63+
/**
64+
* Converts the result of [RegExp.exec] to an array where the first element contains the entire matched text and each subsequent
65+
* element is the text matched by each capturing parenthesis.
66+
*/
67+
public inline fun RegExpMatch.asArray(): Array<out String?> = unsafeCast<Array<out String?>>()

js/js.libraries/src/reflect/JsClass.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ import getKClass
2020
import kotlin.reflect.KClass
2121
import kotlin.reflect.js.internal.KClassImpl
2222

23+
/**
24+
* Represents the constructor of a class. Instances of `JsClass` can be passed to JavaScript APIs that expect a constructor reference.
25+
*/
2326
external interface JsClass<T : Any> {
27+
/**
28+
* Returns the unqualified name of the class represented by this instance.
29+
*/
2430
val name: String
2531
}
2632

@@ -31,8 +37,14 @@ external fun <T : Any> jsClass(): JsClass<T>
3137
val <T : Any> T.jsClass: JsClass<T>
3238
get() = js("Object").getPrototypeOf(this).constructor
3339

40+
/**
41+
* Obtains a constructor reference for the given `KClass`.
42+
*/
3443
val <T : Any> KClass<T>.js: JsClass<T>
3544
get() = (this as KClassImpl<T>).jClass
3645

46+
/**
47+
* Obtains a `KClass` instance for the given constructor reference.
48+
*/
3749
val <T : Any> JsClass<T>.kotlin: KClass<T>
3850
get() = getKClass(this)

libraries/stdlib/src/Module.md

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Core functions and types, available on all supported platforms.
1717

1818
Library support for the Kotlin annotation facility.
1919

20+
# Package kotlin.browser
21+
22+
Access to top-level properties (`document`, `window` etc.) in the browser environment.
23+
2024
# Package kotlin.collections
2125

2226
Collection types, such as [Iterable][kotlin.collections.Iterable], [Collection][kotlin.collections.Collection],
@@ -30,10 +34,30 @@ Helper functions for creating [Comparator][java.util.Comparator] instances.
3034

3135
Utility functions for concurrent programming.
3236

37+
# Package kotlin.coroutines.experimental
38+
39+
Library support for coroutines, including support for lazy sequences.
40+
41+
# Package kotlin.coroutines.experimental.intrinsics
42+
43+
Low-level building blocks for libraries that provide coroutine-based APIs.
44+
45+
# Package kotlin.dom
46+
47+
Utility functions for working with the browser DOM.
48+
49+
# Package kotlin.experimental
50+
51+
Experimental APIs, subject to change in future versions of Kotlin.
52+
3353
# Package kotlin.io
3454

3555
IO API for working with files and streams.
3656

57+
# Package kotlin.js
58+
59+
Functions and other APIs specific to the JavaScript platform.
60+
3761
# Package kotlin.jvm
3862

3963
Functions and annotations specific to the Java platform.
@@ -51,16 +75,24 @@ and helper functions for implementing custom delegates.
5175

5276
Runtime API for [Kotlin reflection](/docs/reference/reflection.html)
5377

78+
# Package kotlin.reflect.full
79+
80+
Extensions for [Kotlin reflection](/docs/reference/reflection.html) provided by `kotlin-reflect` library.
81+
5482
# Package kotlin.reflect.jvm
5583

5684
Runtime API for interoperability between [Kotlin reflection](/docs/reference/reflection.html) and
57-
Java reflection.
85+
Java reflection provided by `kotlin-reflect` library.
5886

5987
# Package kotlin.sequences
6088

6189
[Sequence][kotlin.sequences.Sequence] type that represents lazily evaluated collections. Top-level functions for instantiating sequences
6290
and extension functions for sequences.
6391

92+
# Package kotlin.streams
93+
94+
Utility functions for working with Java 8 [streams](https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html).
95+
6496
# Package kotlin.system
6597

6698
System-related utility functions.
@@ -73,3 +105,55 @@ Functions for writing test assertions.
73105

74106
Functions for working with text and regular expressions.
75107

108+
# Package org.khronos.webgl
109+
110+
Kotlin JavaScript wrappers for the WebGL API.
111+
112+
# Package org.w3c.dom
113+
114+
Kotlin JavaScript wrappers for the DOM API.
115+
116+
# Package org.w3c.dom.css
117+
118+
Kotlin JavaScript wrappers for the DOM CSS API.
119+
120+
# Package org.w3c.dom.events
121+
122+
Kotlin JavaScript wrappers for the DOM events API.
123+
124+
# Package org.w3c.dom.parsing
125+
126+
Kotlin JavaScript wrappers for the DOM parsing API.
127+
128+
# Package org.w3c.dom.svg
129+
130+
Kotlin JavaScript wrappers for the DOM SVG API.
131+
132+
# Package org.w3c.dom.url
133+
134+
Kotlin JavaScript wrappers for the DOM URL API.
135+
136+
# Package org.w3c.fetch
137+
138+
Kotlin JavaScript wrappers for the [W3C fetch API](https://fetch.spec.whatwg.org).
139+
140+
# Package org.w3c.files
141+
142+
Kotlin JavaScript wrappers for the [W3C file API](https://www.w3.org/TR/FileAPI/).
143+
144+
# Package org.w3c.notifications
145+
146+
Kotlin JavaScript wrappers for the [Web Notifications API](https://www.w3.org/TR/notifications/).
147+
148+
# Package org.w3c.performance
149+
150+
Kotlin JavaScript wrappers for the [Navigation Timing API](https://www.w3.org/TR/navigation-timing/).
151+
152+
# Package org.w3c.workers
153+
154+
Kotlin JavaScript wrappers for the [Web Workers API](https://www.w3.org/TR/workers/).
155+
156+
# Package org.w3c.xhr
157+
158+
Kotlin JavaScript wrappers for the [XMLHttpRequest API](https://www.w3.org/TR/XMLHttpRequest/).
159+

libraries/stdlib/src/kotlin/coroutines/experimental/jvm/internal/CoroutineImpl.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@
1818
package kotlin.coroutines.experimental.jvm.internal
1919

2020
import java.lang.IllegalStateException
21-
import kotlin.coroutines.experimental.*
22-
import kotlin.coroutines.experimental.jvm.internal.interceptContinuationIfNeeded
21+
import kotlin.coroutines.experimental.Continuation
22+
import kotlin.coroutines.experimental.CoroutineContext
23+
import kotlin.coroutines.experimental.processBareContinuationResume
2324
import kotlin.jvm.internal.Lambda
2425

26+
/**
27+
* @suppress
28+
*/
2529
abstract class CoroutineImpl(
2630
arity: Int,
2731
@JvmField

libraries/stdlib/src/kotlin/coroutines/experimental/jvm/internal/CoroutineIntrinsics.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
package kotlin.coroutines.experimental.jvm.internal
2020

2121
import kotlin.coroutines.experimental.Continuation
22-
import kotlin.coroutines.experimental.CoroutineContext
2322
import kotlin.coroutines.experimental.ContinuationInterceptor
24-
import kotlin.coroutines.experimental.jvm.internal.CoroutineImpl
23+
import kotlin.coroutines.experimental.CoroutineContext
2524

25+
/**
26+
* @suppress
27+
*/
2628
fun <T> normalizeContinuation(continuation: Continuation<T>): Continuation<T> =
2729
(continuation as? CoroutineImpl)?.facade ?: continuation
2830

0 commit comments

Comments
 (0)