Skip to content

Commit 099c8e2

Browse files
convert kdocs fixes
1 parent 2efff53 commit 099c8e2

File tree

5 files changed

+31
-16
lines changed

5 files changed

+31
-16
lines changed

core/api/core.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,7 @@ public final class org/jetbrains/kotlinx/dataframe/api/ConvertKt {
15291529
public static final fun convertToStringFromT (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn;
15301530
public static final fun convertToURL (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn;
15311531
public static final fun convertToURLFromStringNullable (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn;
1532+
public static final fun to (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlin/jvm/functions/Function2;)Lorg/jetbrains/kotlinx/dataframe/DataFrame;
15321533
public static final fun to (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlin/reflect/KType;)Lorg/jetbrains/kotlinx/dataframe/DataFrame;
15331534
public static final fun toBigDecimal (Lorg/jetbrains/kotlinx/dataframe/api/Convert;)Lorg/jetbrains/kotlinx/dataframe/DataFrame;
15341535
public static final fun toBigDecimalTAny (Lorg/jetbrains/kotlinx/dataframe/api/Convert;)Lorg/jetbrains/kotlinx/dataframe/DataFrame;

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import kotlinx.datetime.LocalDateTime
66
import kotlinx.datetime.LocalTime
77
import kotlinx.datetime.TimeZone
88
import kotlinx.datetime.toLocalDateTime
9+
import org.jetbrains.kotlinx.dataframe.AnyBaseCol
910
import org.jetbrains.kotlinx.dataframe.AnyCol
1011
import org.jetbrains.kotlinx.dataframe.AnyFrame
1112
import org.jetbrains.kotlinx.dataframe.ColumnsContainer
1213
import org.jetbrains.kotlinx.dataframe.ColumnsSelector
1314
import org.jetbrains.kotlinx.dataframe.DataColumn
1415
import org.jetbrains.kotlinx.dataframe.DataFrame
16+
import org.jetbrains.kotlinx.dataframe.DataFrameExpression
1517
import org.jetbrains.kotlinx.dataframe.DataRow
1618
import org.jetbrains.kotlinx.dataframe.RowColumnExpression
1719
import org.jetbrains.kotlinx.dataframe.RowValueExpression
@@ -46,6 +48,8 @@ import org.jetbrains.kotlinx.dataframe.impl.api.withRowCellImpl
4648
import org.jetbrains.kotlinx.dataframe.impl.headPlusArray
4749
import org.jetbrains.kotlinx.dataframe.impl.io.FastDoubleParser
4850
import org.jetbrains.kotlinx.dataframe.io.toDataFrame
51+
import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO
52+
import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_REPLACE
4953
import java.math.BigDecimal
5054
import java.math.BigInteger
5155
import java.net.URL
@@ -79,8 +83,7 @@ internal interface SeeAlsoParse
7983
* Additionally, it offers a wide range of methods for converting to specific types,
8084
* such as [toStr][Convert.toStr], [toDouble][Convert.toDouble], and many others.
8185
*
82-
* For the full list of supported types,
83-
* refer to the [documentation website]({@include [DocumentationUrls.Url]}/convert.html).
86+
* For the full list of supported types, see [SupportedTypes].
8487
*
8588
* Each method returns a new [DataFrame] with the updated columns.
8689
*
@@ -102,6 +105,18 @@ internal interface ConvertDocs {
102105
*/
103106
interface ConvertSelectingOptions
104107

108+
/**
109+
* List of types, supported in [convert to][Convert.to] operation:
110+
* * [String] (uses parse to convert from String to other types);
111+
* * [Boolean];
112+
* * [Byte], [Short], [Char];
113+
* * [Int], [Long], [Float], [Double];
114+
* * [BigDecimal], [BigInteger];
115+
* * [LocalDateTime], [LocalDate], [LocalTime], [Instant] ( (kotlinx.datetime and [java.time]),
116+
* * [URL], [IMG], [IFRAME].
117+
*/
118+
interface SupportedTypes
119+
105120
/**
106121
* ## Convert Operation Grammar
107122
* {@include [LineBreak]}
@@ -123,9 +138,6 @@ internal interface ConvertDocs {
123138
* `| `__`.`__[**`to`**][Convert.to]`(type: `[`KType`][KType]`)`
124139
*
125140
* {@include [Indent]}
126-
* `| `__`.`__[**`to`**][Convert.to]` { columnConverter: `[`DataFrame`](DataFrame)`.(`[`DataColumn`](DataColumn)`) -> `[`AnyBaseColumn`](AnyBaseColumn)` }`
127-
*
128-
* {@include [Indent]}
129141
* `| `__`.`__[**`perRowCol`**][Convert.perRowCol]` { expression: `[`RowColumnExpression`][RowColumnExpression]` }`
130142
*
131143
* {@include [Indent]}
@@ -293,7 +305,7 @@ public inline fun <T, C, reified R> Convert<T, C?>.notNull(
293305
*
294306
* Use the following methods to perform the conversion:
295307
* - [to(kType)][to]/[to`<Type`>()][to] – converts columns to a specific type.
296-
* - [to { columnConverter }][to] - converts columns using column converter expression.
308+
* - [asColumn { columnConverter }][asColumn] - converts columns using column converter expression.
297309
* - [with][Convert.with] – applies a custom row-wise conversion expression.
298310
* - [notNull][Convert.notNull] – like [with], but only for non-null values.
299311
* - [perRowCol][Convert.perRowCol] – applies a conversion that uses both column and row information.
@@ -324,8 +336,7 @@ public class Convert<T, out C>(
324336
* preserving their original names and positions within the [DataFrame].
325337
*
326338
* The target type is provided as a reified type argument.
327-
* For the full list of supported types,
328-
* refer to the [documentation website]({@include [DocumentationUrls.Url]}/convert.html).
339+
* For the full list of supported types, see [ConvertDocs.SupportedTypes].
329340
*
330341
* For more information: {@include [DocumentationUrls.Convert]}
331342
*
@@ -353,8 +364,7 @@ public class Convert<T, out C>(
353364
* preserving their original names and positions within the [DataFrame].
354365
*
355366
* The target type is provided as a [KType].
356-
* For the full list of supported types,
357-
* refer to the [documentation website]({@include [DocumentationUrls.Url]}/convert.html).
367+
* For the full list of supported types, see [ConvertDocs.SupportedTypes].
358368
*
359369
* For more information: {@include [DocumentationUrls.Convert]}
360370
*
@@ -372,6 +382,10 @@ public class Convert<T, out C>(
372382
*/
373383
public fun <T> Convert<T, *>.to(type: KType): DataFrame<T> = asColumn { it.convertTo(type) }
374384

385+
@Deprecated(CONVERT_TO, ReplaceWith(CONVERT_TO_REPLACE), DeprecationLevel.ERROR)
386+
public fun <T, C> Convert<T, C>.to(columnConverter: DataFrame<T>.(DataColumn<C>) -> AnyBaseCol): DataFrame<T> =
387+
df.replace(columns).with { columnConverter(df, it) }
388+
375389
/** [Convert per row col][Convert.perRowCol] to provide a new value for every selected cell giving its column. */
376390
@ExcludeFromSources
377391
private interface SeeAlsoConvertPerRowCol
@@ -512,8 +526,7 @@ public inline fun <T, C, reified R> Convert<T, C>.perRowCol(
512526
*
513527
* The target type is provided as a reified type argument.
514528
*
515-
* For the full list of supported types,
516-
* refer to the [documentation website]({@include [DocumentationUrls.Url]}/convert.html).
529+
* For the full list of supported types, see [ConvertDocs.SupportedTypes].
517530
*
518531
* @param [C] The target type to convert values to.
519532
* @return A new [DataColumn] with the values converted to type [C].
@@ -523,8 +536,7 @@ public inline fun <reified C> AnyCol.convertTo(): DataColumn<C> = convertTo(type
523536
/**
524537
* Converts values in this column to the specified [type].
525538
*
526-
* For the full list of supported types,
527-
* refer to the [documentation website]({@include [DocumentationUrls.Url]}/convert.html).
539+
* For the full list of supported types, see [ConvertDocs.SupportedTypes].
528540
*
529541
* @param type The target type, provided as a [KType], to convert values to.
530542
* @return A new [DataColumn] with the values converted to [type].

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/replace.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public fun <T, C> ReplaceClause<T, C>.with(newColumns: List<AnyCol>): DataFrame<
5555
// TODO: Issue #418: breaks if running on ColumnGroup and its child
5656

5757
/**
58-
* For an alternative supported in the compiler plugin use [Convert.to]
58+
* For an alternative supported in the compiler plugin use [Convert.asColumn]
5959
*/
6060
public fun <T, C> ReplaceClause<T, C>.with(transform: ColumnsContainer<T>.(DataColumn<C>) -> AnyBaseCol): DataFrame<T> {
6161
val removeResult = df.removeImpl(columns = columns)

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import org.jetbrains.kotlinx.dataframe.DataRow
1818
import org.jetbrains.kotlinx.dataframe.api.GlobalParserOptions
1919
import org.jetbrains.kotlinx.dataframe.api.ParserOptions
2020
import org.jetbrains.kotlinx.dataframe.api.asColumn
21-
import org.jetbrains.kotlinx.dataframe.api.to
2221
import org.jetbrains.kotlinx.dataframe.api.asColumnGroup
2322
import org.jetbrains.kotlinx.dataframe.api.asDataColumn
2423
import org.jetbrains.kotlinx.dataframe.api.cast

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ internal const val MAX_NO_SKIPNAN = "This function is just here for binary compa
9292
internal const val MIN_NO_SKIPNAN = "This function is just here for binary compatibility. $MESSAGE_0_16"
9393
internal const val MEAN_NO_SKIPNAN = "This function is just here for binary compatibility. $MESSAGE_0_16"
9494

95+
internal const val CONVERT_TO = "This to overload will be removed in favor of `asColumn`. $MESSAGE_0_16"
96+
internal const val CONVERT_TO_REPLACE = "this.asColumn(columnConverter)"
97+
9598
// endregion
9699

97100
// region WARNING in 0.16, ERROR in 0.17

0 commit comments

Comments
 (0)