stdlib-gen: make 'sample' overwrite samples list instead of adding
It's more common for a function to have the single sample, and it's more convenient to override it in `specialFor` blocks, rather than to append another one.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -43,8 +43,9 @@ object SequenceOps : TemplateGroupBase() {
|
|||||||
Creates a [Sequence] instance that wraps the original ${f.collection} returning its ${f.element.pluralize()} when being iterated.
|
Creates a [Sequence] instance that wraps the original ${f.collection} returning its ${f.element.pluralize()} when being iterated.
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
if (f in listOf(ArraysOfPrimitives, ArraysOfObjects, Iterables))
|
specialFor(ArraysOfPrimitives, ArraysOfObjects, Iterables) {
|
||||||
sample("samples.collections.Sequences.Building.sequenceFrom${f.doc.collection.capitalize()}")
|
sample("samples.collections.Sequences.Building.sequenceFrom${f.doc.collection.capitalize()}")
|
||||||
|
}
|
||||||
|
|
||||||
returns("Sequence<T>")
|
returns("Sequence<T>")
|
||||||
body {
|
body {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ class MemberBuilder(
|
|||||||
|
|
||||||
var doc: String? = null; private set
|
var doc: String? = null; private set
|
||||||
|
|
||||||
val samples = mutableListOf<String>()
|
var samples = listOf<String>()
|
||||||
|
|
||||||
val sequenceClassification = mutableListOf<SequenceClass>()
|
val sequenceClassification = mutableListOf<SequenceClass>()
|
||||||
var deprecate: Deprecation? = null; private set
|
var deprecate: Deprecation? = null; private set
|
||||||
@@ -134,8 +134,8 @@ class MemberBuilder(
|
|||||||
@Deprecated("Use specialFor", ReplaceWith("specialFor(*fs) { doc(valueBuilder) }"))
|
@Deprecated("Use specialFor", ReplaceWith("specialFor(*fs) { doc(valueBuilder) }"))
|
||||||
fun doc(vararg fs: Family, valueBuilder: DocExtensions.() -> String) = specialFor(*fs) { doc(valueBuilder) }
|
fun doc(vararg fs: Family, valueBuilder: DocExtensions.() -> String) = specialFor(*fs) { doc(valueBuilder) }
|
||||||
|
|
||||||
fun sample(sampleRef: String) {
|
fun sample(vararg sampleRef: String) {
|
||||||
samples += sampleRef
|
samples = sampleRef.asList()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun body(valueBuilder: () -> String) {
|
fun body(valueBuilder: () -> String) {
|
||||||
|
|||||||
Reference in New Issue
Block a user