diff --git a/libraries/stdlib/common/src/generated/_Sequences.kt b/libraries/stdlib/common/src/generated/_Sequences.kt index c90be378ef3..43e19f1acf8 100644 --- a/libraries/stdlib/common/src/generated/_Sequences.kt +++ b/libraries/stdlib/common/src/generated/_Sequences.kt @@ -332,10 +332,10 @@ public inline fun Sequence.singleOrNull(predicate: (T) -> Boolean): T? { /** * Returns a sequence containing all elements except first [n] elements. - * - * @sample samples.collections.Collections.Transformations.drop * * The operation is _intermediate_ and _stateless_. + * + * @sample samples.collections.Collections.Transformations.drop */ public fun Sequence.drop(n: Int): Sequence { require(n >= 0) { "Requested element count $n is less than zero." } @@ -348,10 +348,10 @@ public fun Sequence.drop(n: Int): Sequence { /** * Returns a sequence containing all elements except first elements that satisfy the given [predicate]. - * - * @sample samples.collections.Collections.Transformations.drop * * The operation is _intermediate_ and _stateless_. + * + * @sample samples.collections.Collections.Transformations.drop */ public fun Sequence.dropWhile(predicate: (T) -> Boolean): Sequence { return DropWhileSequence(this, predicate) @@ -463,10 +463,10 @@ public inline fun > Sequence.filterTo(destinat /** * Returns a sequence containing first [n] elements. - * - * @sample samples.collections.Collections.Transformations.take * * The operation is _intermediate_ and _stateless_. + * + * @sample samples.collections.Collections.Transformations.take */ public fun Sequence.take(n: Int): Sequence { require(n >= 0) { "Requested element count $n is less than zero." } @@ -479,10 +479,10 @@ public fun Sequence.take(n: Int): Sequence { /** * Returns a sequence containing first elements satisfying the given [predicate]. - * - * @sample samples.collections.Collections.Transformations.take * * The operation is _intermediate_ and _stateless_. + * + * @sample samples.collections.Collections.Transformations.take */ public fun Sequence.takeWhile(predicate: (T) -> Boolean): Sequence { return TakeWhileSequence(this, predicate) @@ -710,10 +710,10 @@ public inline fun > Sequence.flatMapTo(dest * applied to each element and returns a map where each group key is associated with a list of corresponding elements. * * The returned map preserves the entry iteration order of the keys produced from the original sequence. - * - * @sample samples.collections.Collections.Transformations.groupBy * * The operation is _terminal_. + * + * @sample samples.collections.Collections.Transformations.groupBy */ public inline fun Sequence.groupBy(keySelector: (T) -> K): Map> { return groupByTo(LinkedHashMap>(), keySelector) @@ -725,10 +725,10 @@ public inline fun Sequence.groupBy(keySelector: (T) -> K): Map Sequence.groupBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map> { return groupByTo(LinkedHashMap>(), keySelector, valueTransform) @@ -739,10 +739,10 @@ public inline fun Sequence.groupBy(keySelector: (T) -> K, valueTran * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements. * * @return The [destination] map. - * - * @sample samples.collections.Collections.Transformations.groupBy * * The operation is _terminal_. + * + * @sample samples.collections.Collections.Transformations.groupBy */ public inline fun >> Sequence.groupByTo(destination: M, keySelector: (T) -> K): M { for (element in this) { @@ -759,10 +759,10 @@ public inline fun >> Sequence.group * and puts to the [destination] map each group key associated with a list of corresponding values. * * @return The [destination] map. - * - * @sample samples.collections.Collections.Transformations.groupByKeysAndValues * * The operation is _terminal_. + * + * @sample samples.collections.Collections.Transformations.groupByKeysAndValues */ public inline fun >> Sequence.groupByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M { for (element in this) { @@ -776,10 +776,10 @@ public inline fun >> Sequence.gr /** * Creates a [Grouping] source from a sequence to be used later with one of group-and-fold operations * using the specified [keySelector] function to extract a key from each element. - * - * @sample samples.collections.Collections.Transformations.groupingByEachCount * * The operation is _intermediate_ and _stateless_. + * + * @sample samples.collections.Collections.Transformations.groupingByEachCount */ @SinceKotlin("1.1") public inline fun Sequence.groupingBy(crossinline keySelector: (T) -> K): Grouping { @@ -931,10 +931,10 @@ public fun Sequence.toMutableSet(): MutableSet { /** * Returns `true` if all elements match the given [predicate]. - * - * @sample samples.collections.Collections.Aggregates.all * * The operation is _terminal_. + * + * @sample samples.collections.Collections.Aggregates.all */ public inline fun Sequence.all(predicate: (T) -> Boolean): Boolean { for (element in this) if (!predicate(element)) return false @@ -943,10 +943,10 @@ public inline fun Sequence.all(predicate: (T) -> Boolean): Boolean { /** * Returns `true` if sequence has at least one element. - * - * @sample samples.collections.Collections.Aggregates.any * * The operation is _terminal_. + * + * @sample samples.collections.Collections.Aggregates.any */ public fun Sequence.any(): Boolean { return iterator().hasNext() @@ -954,10 +954,10 @@ public fun Sequence.any(): Boolean { /** * Returns `true` if at least one element matches the given [predicate]. - * - * @sample samples.collections.Collections.Aggregates.anyWithPredicate * * The operation is _terminal_. + * + * @sample samples.collections.Collections.Aggregates.anyWithPredicate */ public inline fun Sequence.any(predicate: (T) -> Boolean): Boolean { for (element in this) if (predicate(element)) return true @@ -1225,10 +1225,10 @@ public fun Sequence.minWith(comparator: Comparator): T? { /** * Returns `true` if the sequence has no elements. - * - * @sample samples.collections.Collections.Aggregates.none * * The operation is _terminal_. + * + * @sample samples.collections.Collections.Aggregates.none */ public fun Sequence.none(): Boolean { return !iterator().hasNext() @@ -1236,10 +1236,10 @@ public fun Sequence.none(): Boolean { /** * Returns `true` if no elements match the given [predicate]. - * - * @sample samples.collections.Collections.Aggregates.noneWithPredicate * * The operation is _terminal_. + * + * @sample samples.collections.Collections.Aggregates.noneWithPredicate */ public inline fun Sequence.none(predicate: (T) -> Boolean): Boolean { for (element in this) if (predicate(element)) return false @@ -1334,10 +1334,10 @@ public fun Sequence.requireNoNulls(): Sequence { * The last list in the resulting sequence may have less elements than the given [size]. * * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this sequence. - * - * @sample samples.collections.Collections.Transformations.chunked * * The operation is _intermediate_ and _stateful_. + * + * @sample samples.collections.Collections.Transformations.chunked */ @SinceKotlin("1.2") public fun Sequence.chunked(size: Int): Sequence> { @@ -1355,10 +1355,10 @@ public fun Sequence.chunked(size: Int): Sequence> { * The last list may have less elements than the given [size]. * * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this sequence. - * - * @sample samples.text.Strings.chunkedTransform * * The operation is _intermediate_ and _stateful_. + * + * @sample samples.text.Strings.chunkedTransform */ @SinceKotlin("1.2") public fun Sequence.chunked(size: Int, transform: (List) -> R): Sequence { @@ -1567,10 +1567,10 @@ public fun Sequence.windowed(size: Int, step: Int = 1, partialWindows: /** * Returns a sequence of values built from the elements of `this` sequence and the [other] sequence with the same index. * The resulting sequence ends as soon as the shortest input sequence ends. - * - * @sample samples.collections.Sequences.Transformations.zip * * The operation is _intermediate_ and _stateless_. + * + * @sample samples.collections.Sequences.Transformations.zip */ public infix fun Sequence.zip(other: Sequence): Sequence> { return MergingSequence(this, other) { t1, t2 -> t1 to t2 } @@ -1580,10 +1580,10 @@ public infix fun Sequence.zip(other: Sequence): Sequence * Returns a sequence of values built from the elements of `this` sequence and the [other] sequence with the same index * using the provided [transform] function applied to each pair of elements. * The resulting sequence ends as soon as the shortest input sequence ends. - * - * @sample samples.collections.Sequences.Transformations.zipWithTransform * * The operation is _intermediate_ and _stateless_. + * + * @sample samples.collections.Sequences.Transformations.zipWithTransform */ public fun Sequence.zip(other: Sequence, transform: (a: T, b: R) -> V): Sequence { return MergingSequence(this, other, transform) @@ -1593,10 +1593,10 @@ public fun Sequence.zip(other: Sequence, transform: (a: T, b: R) * Returns a sequence of pairs of each two adjacent elements in this sequence. * * The returned sequence is empty if this sequence contains less than two elements. - * - * @sample samples.collections.Collections.Transformations.zipWithNext * * The operation is _intermediate_ and _stateless_. + * + * @sample samples.collections.Collections.Transformations.zipWithNext */ @SinceKotlin("1.2") public fun Sequence.zipWithNext(): Sequence> { @@ -1608,10 +1608,10 @@ public fun Sequence.zipWithNext(): Sequence> { * to an each pair of two adjacent elements in this sequence. * * The returned sequence is empty if this sequence contains less than two elements. - * - * @sample samples.collections.Collections.Transformations.zipWithNextToFindDeltas * * The operation is _intermediate_ and _stateless_. + * + * @sample samples.collections.Collections.Transformations.zipWithNextToFindDeltas */ @SinceKotlin("1.2") public fun Sequence.zipWithNext(transform: (a: T, b: T) -> R): Sequence { @@ -1632,10 +1632,10 @@ public fun Sequence.zipWithNext(transform: (a: T, b: T) -> R): Sequenc * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). - * - * @sample samples.collections.Collections.Transformations.joinTo * * The operation is _terminal_. + * + * @sample samples.collections.Collections.Transformations.joinTo */ public fun Sequence.joinTo(buffer: A, separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): A { buffer.append(prefix) @@ -1656,10 +1656,10 @@ public fun Sequence.joinTo(buffer: A, separator: CharSequ * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). - * - * @sample samples.collections.Collections.Transformations.joinToString * * The operation is _terminal_. + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun Sequence.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/MemberBuilder.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/MemberBuilder.kt index 84f9141321c..0cd2678bd16 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/MemberBuilder.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/MemberBuilder.kt @@ -305,14 +305,14 @@ class MemberBuilder( StringReader(methodDoc.trim()).forEachLine { line -> builder.append(" * ").append(line.trim()).append("\n") } - if (samples.any()) { - builder.append(" * \n") - samples.forEach { builder.append(" * @sample $it\n")} - } if (family == Sequences && sequenceClassification.isNotEmpty()) { builder.append(" *\n") builder.append(" * The operation is ${sequenceClassification.joinToString(" and ") { "_${it}_" }}.\n") } + if (samples.any()) { + builder.append(" * \n") + samples.forEach { builder.append(" * @sample $it\n")} + } builder.append(" */\n") }