Add samples for take* and drop* extensions (KT-20357)

- Add samples for take, takeLast, takeWhile, takeLastWhile
- Add samples for drop, dropLast, dropWhile, dropLastWhile
This commit is contained in:
gzoritchak
2018-02-20 00:45:48 +01:00
committed by Ilya Gorbunov
parent fda40723dc
commit 1c1fe10e12
8 changed files with 562 additions and 14 deletions
@@ -48,7 +48,13 @@ object Filtering : TemplateGroupBase() {
include(CharSequences, Strings)
} builder {
val n = "\$n"
doc { "Returns a list containing all elements except first [n] elements." }
doc {
"""
Returns a list containing all elements except first [n] elements.
@sample samples.collections.Collections.Transformations.drop
"""
}
returns("List<T>")
body {
"""
@@ -129,7 +135,13 @@ object Filtering : TemplateGroupBase() {
include(CharSequences, Strings)
} builder {
val n = "\$n"
doc { "Returns a list containing first [n] elements." }
doc {
"""
Returns a list containing first [n] elements.
@sample samples.collections.Collections.Transformations.take
"""
}
returns("List<T>")
body {
"""
@@ -204,7 +216,13 @@ object Filtering : TemplateGroupBase() {
} builder {
val n = "\$n"
doc { "Returns a list containing all elements except last [n] elements." }
doc {
"""
Returns a list containing all elements except last [n] elements.
@sample samples.collections.Collections.Transformations.drop
"""
}
returns("List<T>")
body {
"""
@@ -228,7 +246,14 @@ object Filtering : TemplateGroupBase() {
include(Lists, ArraysOfObjects, ArraysOfPrimitives, CharSequences, Strings)
} builder {
val n = "\$n"
doc { "Returns a list containing last [n] elements." }
doc {
"""
Returns a list containing last [n] elements.
@sample samples.collections.Collections.Transformations.take
"""
}
returns("List<T>")
specialFor(Strings, CharSequences) {
returns("SELF")
@@ -288,7 +313,13 @@ object Filtering : TemplateGroupBase() {
} builder {
inline()
doc { "Returns a list containing all elements except first elements that satisfy the given [predicate]." }
doc {
"""
Returns a list containing all elements except first elements that satisfy the given [predicate].
@sample samples.collections.Collections.Transformations.drop
"""
}
returns("List<T>")
body {
"""
@@ -339,7 +370,13 @@ object Filtering : TemplateGroupBase() {
} builder {
inline()
doc { "Returns a list containing first elements satisfying the given [predicate]." }
doc {
"""
Returns a list containing first elements satisfying the given [predicate].
@sample samples.collections.Collections.Transformations.take
"""
}
returns("List<T>")
body {
"""
@@ -384,7 +421,13 @@ object Filtering : TemplateGroupBase() {
include(Lists, ArraysOfObjects, ArraysOfPrimitives, CharSequences, Strings)
} builder {
inline()
doc { "Returns a list containing all elements except last elements that satisfy the given [predicate]." }
doc {
"""
Returns a list containing all elements except last elements that satisfy the given [predicate].
@sample samples.collections.Collections.Transformations.drop
"""
}
returns("List<T>")
body {
@@ -435,7 +478,13 @@ object Filtering : TemplateGroupBase() {
include(Lists, ArraysOfObjects, ArraysOfPrimitives, CharSequences, Strings)
} builder {
inline()
doc { "Returns a list containing last elements satisfying the given [predicate]."}
doc {
"""
Returns a list containing last elements satisfying the given [predicate].
@sample samples.collections.Collections.Transformations.take
"""
}
returns("List<T>")
body {