Skip to content

Commit a8d5b9b

Browse files
Automated commit of generated code
1 parent c0c7b7f commit a8d5b9b

File tree

16 files changed

+164
-85
lines changed

16 files changed

+164
-85
lines changed

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

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,13 @@ import org.jetbrains.kotlinx.dataframe.impl.io.FastDoubleParser
4242
import org.jetbrains.kotlinx.dataframe.io.toDataFrame
4343
import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO
4444
import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_REPLACE
45+
import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_URL
46+
import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_URL_REPLACE
47+
import org.jetbrains.kotlinx.dataframe.util.TO_URL
48+
import org.jetbrains.kotlinx.dataframe.util.TO_URL_REPLACE
4549
import java.math.BigDecimal
4650
import java.math.BigInteger
51+
import java.net.URI
4752
import java.net.URL
4853
import java.util.Locale
4954
import kotlin.reflect.KProperty
@@ -242,7 +247,7 @@ internal interface ConvertDocs {
242247
* `| `__`.`__[**`toInstant`**][Convert.toInstant]`()`
243248
*
244249
*     
245-
* `| `__`.`__[**`toURL`**][Convert.toURL]`()`
250+
* `| `__`.`__[**`toUrl`**][Convert.toUrl]`()`
246251
*
247252
*     
248253
* `| `__`.`__[**`toIFrame`**][Convert.toIFrame]`()`
@@ -464,7 +469,7 @@ public inline fun <T, C, reified R> Convert<T, C?>.notNull(
464469
* - [toStr], [toInt], [toLong], [toDouble], [toFloat], [toBigDecimal],
465470
* [toBigInteger], [toBoolean] – convert to standard types.
466471
* - [toLocalDateTime], [toLocalDate], [toLocalTime], [toInstant] – convert to kotlinx.datetime types.
467-
* - [toURL], [toIFrame], [toImg] – convert to special types.
472+
* - [toUrl], [toIFrame], [toImg] – convert to special types.
468473
* - [toDataFrames] – converts a column of lists into separate DataFrames.
469474
*
470475
* See [Grammar][ConvertDocs.Grammar] for more details.
@@ -1109,20 +1114,34 @@ public fun <T, R : URL?> Convert<T, URL>.toImg(width: Int? = null, height: Int?
11091114

11101115
// region toURL
11111116

1117+
@Deprecated(CONVERT_TO_URL, ReplaceWith(CONVERT_TO_URL_REPLACE), DeprecationLevel.ERROR)
1118+
public fun DataColumn<String>.convertToURL(): DataColumn<URL> = convertToUrl()
1119+
11121120
/**
11131121
* Converts values in this [String] column to an [URL].
11141122
*
11151123
* @return A new [DataColumn] with an [URL] values.
11161124
*/
1117-
public fun DataColumn<String>.convertToURL(): DataColumn<URL> = map { URL(it) }
1125+
public fun DataColumn<String>.convertToUrl(): DataColumn<URL> = map { URI(it).toURL() }
1126+
1127+
@Deprecated(CONVERT_TO_URL, ReplaceWith(CONVERT_TO_URL_REPLACE), DeprecationLevel.ERROR)
1128+
@JvmName("convertToURLFromStringNullable")
1129+
public fun DataColumn<String?>.convertToURL(): DataColumn<URL?> = convertToUrl()
11181130

11191131
/**
11201132
* Converts values in this [String] column to an [URL]. Preserves null values.
11211133
*
11221134
* @return A new [DataColumn] with an [URL] nullable values.
11231135
*/
1124-
@JvmName("convertToURLFromStringNullable")
1125-
public fun DataColumn<String?>.convertToURL(): DataColumn<URL?> = map { it?.let { URL(it) } }
1136+
@JvmName("convertToUrlFromStringNullable")
1137+
public fun DataColumn<String?>.convertToUrl(): DataColumn<URL?> = map { it?.let { URI(it).toURL() } }
1138+
1139+
@Deprecated(TO_URL, ReplaceWith(TO_URL_REPLACE), DeprecationLevel.ERROR)
1140+
@JvmName("toURLFromStringNullable")
1141+
@Refine
1142+
@Converter(URL::class, nullable = true)
1143+
@Interpretable("ToSpecificType")
1144+
public fun <T> Convert<T, String?>.toURL(): DataFrame<T> = asColumn { it.convertToUrl() }
11261145

11271146
/**
11281147
* Converts values in the [String] columns previously selected with [convert] to an [URL],
@@ -1133,7 +1152,7 @@ public fun DataColumn<String?>.convertToURL(): DataColumn<URL?> = map { it?.let
11331152
*
11341153
* ### Examples:
11351154
* ```kotlin
1136-
* df.convert { webAddress }.toURL()
1155+
* df.convert { webAddress }.toUrl()
11371156
* ```
11381157
*
11391158
* @return A new [DataFrame] with the values converted to an [URL].
@@ -1142,7 +1161,14 @@ public fun DataColumn<String?>.convertToURL(): DataColumn<URL?> = map { it?.let
11421161
@Refine
11431162
@Converter(URL::class, nullable = true)
11441163
@Interpretable("ToSpecificType")
1145-
public fun <T> Convert<T, String?>.toURL(): DataFrame<T> = asColumn { it.convertToURL() }
1164+
public fun <T> Convert<T, String?>.toUrl(): DataFrame<T> = asColumn { it.convertToUrl() }
1165+
1166+
@Deprecated(TO_URL, ReplaceWith(TO_URL_REPLACE), DeprecationLevel.ERROR)
1167+
@JvmName("toURLFromString")
1168+
@Refine
1169+
@Converter(URL::class, nullable = false)
1170+
@Interpretable("ToSpecificType")
1171+
public fun <T> Convert<T, String>.toURL(): DataFrame<T> = toUrl()
11461172

11471173
/**
11481174
* Converts values in the [String] columns previously selected with [convert] to an [URL],
@@ -1152,7 +1178,7 @@ public fun <T> Convert<T, String?>.toURL(): DataFrame<T> = asColumn { it.convert
11521178
*
11531179
* ### Examples:
11541180
* ```kotlin
1155-
* df.convert { webAddress }.toURL()
1181+
* df.convert { webAddress }.toUrl()
11561182
* ```
11571183
*
11581184
* @return A new [DataFrame] with the values converted to an [URL].
@@ -1161,7 +1187,7 @@ public fun <T> Convert<T, String?>.toURL(): DataFrame<T> = asColumn { it.convert
11611187
@Refine
11621188
@Converter(URL::class, nullable = false)
11631189
@Interpretable("ToSpecificType")
1164-
public fun <T> Convert<T, String>.toURL(): DataFrame<T> = asColumn { it.convertToURL() }
1190+
public fun <T> Convert<T, String>.toUrl(): DataFrame<T> = asColumn { it.convertToUrl() }
11651191

11661192
// endregion
11671193

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/format.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import org.jetbrains.kotlinx.dataframe.impl.api.formatImpl
1515
import org.jetbrains.kotlinx.dataframe.impl.api.linearGradient
1616
import org.jetbrains.kotlinx.dataframe.io.DataFrameHtmlData
1717
import org.jetbrains.kotlinx.dataframe.io.DisplayConfiguration
18-
import org.jetbrains.kotlinx.dataframe.io.toHTML
19-
import org.jetbrains.kotlinx.dataframe.io.toStandaloneHTML
18+
import org.jetbrains.kotlinx.dataframe.io.toHtml
19+
import org.jetbrains.kotlinx.dataframe.io.toStandaloneHtml
2020
import kotlin.reflect.KProperty
2121

2222
// region DataFrame
@@ -126,14 +126,14 @@ public class FormattedFrame<T>(internal val df: DataFrame<T>, internal val forma
126126
/**
127127
* @return DataFrameHtmlData without additional definitions. Can be rendered in Jupyter kernel environments
128128
*/
129-
public fun toHTML(configuration: DisplayConfiguration = DisplayConfiguration.DEFAULT): DataFrameHtmlData =
130-
df.toHTML(getDisplayConfiguration(configuration))
129+
public fun toHtml(configuration: DisplayConfiguration = DisplayConfiguration.DEFAULT): DataFrameHtmlData =
130+
df.toHtml(getDisplayConfiguration(configuration))
131131

132132
/**
133133
* @return DataFrameHtmlData with table script and css definitions. Can be saved as an *.html file and displayed in the browser
134134
*/
135-
public fun toStandaloneHTML(configuration: DisplayConfiguration = DisplayConfiguration.DEFAULT): DataFrameHtmlData =
136-
df.toStandaloneHTML(getDisplayConfiguration(configuration))
135+
public fun toStandaloneHtml(configuration: DisplayConfiguration = DisplayConfiguration.DEFAULT): DataFrameHtmlData =
136+
df.toStandaloneHtml(getDisplayConfiguration(configuration))
137137

138138
public fun getDisplayConfiguration(configuration: DisplayConfiguration): DisplayConfiguration =
139139
configuration.copy(cellFormatter = formatter as RowColFormatter<*, *>?)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import org.jetbrains.kotlinx.dataframe.io.isUrl
4141
import org.jetbrains.kotlinx.dataframe.values
4242
import java.math.BigDecimal
4343
import java.math.BigInteger
44+
import java.net.URI
4445
import java.net.URL
4546
import java.text.ParsePosition
4647
import java.time.format.DateTimeFormatter
@@ -240,7 +241,7 @@ internal object Parsers : GlobalParserOptions {
240241
toJavaLocalDateTimeOrNull(formatter) // since we accept a Java DateTimeFormatter
241242
?.toKotlinLocalDateTime()
242243

243-
private fun String.toUrlOrNull(): URL? = if (isUrl(this)) catchSilent { URL(this) } else null
244+
private fun String.toUrlOrNull(): URL? = if (isUrl(this)) catchSilent { URI(this).toURL() } else null
244245

245246
private fun String.toBooleanOrNull() =
246247
when (uppercase(Locale.getDefault())) {

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/common.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import org.jetbrains.kotlinx.dataframe.util.IS_URL_REPLACE
1111
import java.io.File
1212
import java.io.InputStream
1313
import java.net.HttpURLConnection
14+
import java.net.URI
1415
import java.net.URL
1516

1617
/**
@@ -110,7 +111,7 @@ public fun isProtocolSupported(url: URL): Boolean = url.protocol in setOf("http"
110111
*/
111112
public fun asUrl(fileOrUrl: String): URL =
112113
if (isUrl(fileOrUrl)) {
113-
URL(fileOrUrl).toURI()
114+
URI(fileOrUrl)
114115
} else {
115116
File(fileOrUrl).also {
116117
require(it.exists()) { "File not found: \"$fileOrUrl\"" }

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/html.kt

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ import org.jetbrains.kotlinx.dataframe.jupyter.RenderedContent
3434
import org.jetbrains.kotlinx.dataframe.name
3535
import org.jetbrains.kotlinx.dataframe.nrow
3636
import org.jetbrains.kotlinx.dataframe.size
37+
import org.jetbrains.kotlinx.dataframe.util.TO_HTML
38+
import org.jetbrains.kotlinx.dataframe.util.TO_HTML_REPLACE
39+
import org.jetbrains.kotlinx.dataframe.util.TO_STANDALONE_HTML
40+
import org.jetbrains.kotlinx.dataframe.util.TO_STANDALONE_HTML_REPLACE
41+
import org.jetbrains.kotlinx.dataframe.util.WRITE_HTML
42+
import org.jetbrains.kotlinx.dataframe.util.WRITE_HTML_REPLACE
3743
import java.awt.Desktop
3844
import java.awt.image.BufferedImage
3945
import java.io.File
@@ -515,6 +521,20 @@ private fun AnyFrame.getColumnsHeaderGrid(): List<List<ColumnWithPathWithBorder<
515521

516522
internal fun DataFrameHtmlData.print() = println(this)
517523

524+
@Deprecated(TO_HTML, ReplaceWith(TO_HTML_REPLACE), DeprecationLevel.ERROR)
525+
public fun <T> DataFrame<T>.toHTML(
526+
configuration: DisplayConfiguration = DisplayConfiguration.DEFAULT,
527+
cellRenderer: CellRenderer = DefaultCellRenderer,
528+
getFooter: (DataFrame<T>) -> String? = { "DataFrame [${it.size}]" },
529+
) = toHtml(configuration, cellRenderer, getFooter)
530+
531+
@Deprecated(TO_STANDALONE_HTML, ReplaceWith(TO_STANDALONE_HTML_REPLACE), DeprecationLevel.ERROR)
532+
public fun <T> DataFrame<T>.toStandaloneHTML(
533+
configuration: DisplayConfiguration = DisplayConfiguration.DEFAULT,
534+
cellRenderer: CellRenderer = DefaultCellRenderer,
535+
getFooter: (DataFrame<T>) -> String? = { "DataFrame [${it.size}]" },
536+
): DataFrameHtmlData = toStandaloneHtml(configuration, cellRenderer, getFooter)
537+
518538
/**
519539
* By default, cell content is formatted as text
520540
* Use [RenderedContent.media] or [IMG], [IFRAME] if you need custom HTML inside a cell.
@@ -524,18 +544,18 @@ internal fun DataFrameHtmlData.print() = println(this)
524544
* the ["Open in browser"](https://www.jetbrains.com/help/idea/editing-html-files.html#ws_html_preview_output_procedure) feature of IntelliJ IDEA will automatically reload the file content when it's updated
525545
* @return DataFrameHtmlData with table script and css definitions
526546
*/
527-
public fun <T> DataFrame<T>.toStandaloneHTML(
547+
public fun <T> DataFrame<T>.toStandaloneHtml(
528548
configuration: DisplayConfiguration = DisplayConfiguration.DEFAULT,
529549
cellRenderer: CellRenderer = DefaultCellRenderer,
530550
getFooter: (DataFrame<T>) -> String? = { "DataFrame [${it.size}]" },
531-
): DataFrameHtmlData = toHTML(configuration, cellRenderer, getFooter).withTableDefinitions()
551+
): DataFrameHtmlData = toHtml(configuration, cellRenderer, getFooter).withTableDefinitions()
532552

533553
/**
534554
* By default, cell content is formatted as text
535555
* Use [RenderedContent.media] or [IMG], [IFRAME] if you need custom HTML inside a cell.
536556
* @return DataFrameHtmlData without additional definitions. Can be rendered in Jupyter kernel environments
537557
*/
538-
public fun <T> DataFrame<T>.toHTML(
558+
public fun <T> DataFrame<T>.toHtml(
539559
configuration: DisplayConfiguration = DisplayConfiguration.DEFAULT,
540560
cellRenderer: CellRenderer = DefaultCellRenderer,
541561
getFooter: (DataFrame<T>) -> String? = { "DataFrame [${it.size}]" },
@@ -620,25 +640,40 @@ public class DataFrameHtmlData(
620640
},
621641
)
622642

643+
public fun writeHtml(destination: File) {
644+
destination.writeText(toString())
645+
}
646+
647+
public fun writeHtml(destination: String) {
648+
File(destination).writeText(toString())
649+
}
650+
651+
public fun writeHtml(destination: Path) {
652+
destination.writeText(toString())
653+
}
654+
655+
@Deprecated(WRITE_HTML, ReplaceWith(WRITE_HTML_REPLACE), DeprecationLevel.ERROR)
623656
public fun writeHTML(destination: File) {
624657
destination.writeText(toString())
625658
}
626659

660+
@Deprecated(WRITE_HTML, ReplaceWith(WRITE_HTML_REPLACE), DeprecationLevel.ERROR)
627661
public fun writeHTML(destination: String) {
628662
File(destination).writeText(toString())
629663
}
630664

665+
@Deprecated(WRITE_HTML, ReplaceWith(WRITE_HTML_REPLACE), DeprecationLevel.ERROR)
631666
public fun writeHTML(destination: Path) {
632667
destination.writeText(toString())
633668
}
634669

635670
/**
636671
* Opens a new tab in your default browser.
637-
* Consider [writeHTML] with the [HTML file auto-reload](https://www.jetbrains.com/help/idea/editing-html-files.html#ws_html_preview_output_procedure) feature of IntelliJ IDEA if you want to experiment with the output and run program multiple times
672+
* Consider [writeHtml] with the [HTML file auto-reload](https://www.jetbrains.com/help/idea/editing-html-files.html#ws_html_preview_output_procedure) feature of IntelliJ IDEA if you want to experiment with the output and run program multiple times
638673
*/
639674
public fun openInBrowser() {
640675
val file = File.createTempFile("df_rendering", ".html")
641-
writeHTML(file)
676+
writeHtml(file)
642677
val uri = file.toURI()
643678
val desktop = Desktop.getDesktop()
644679
desktop.browse(uri)
@@ -680,7 +715,7 @@ public class DataFrameHtmlData(
680715
/**
681716
* @return CSS and JS required to render DataFrame tables
682717
* Can be used as a starting point to create page with multiple tables
683-
* @see DataFrame.toHTML
718+
* @see DataFrame.toHtml
684719
* @see DataFrameHtmlData.plus
685720
*/
686721
public fun tableDefinitions(includeJs: Boolean = true, includeCss: Boolean = true): DataFrameHtmlData =

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/importDataSchema.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package org.jetbrains.kotlinx.dataframe.jupyter
22

33
import org.intellij.lang.annotations.Language
44
import java.io.File
5+
import java.net.URI
56
import java.net.URL
67

78
public class ImportDataSchema(public val url: URL) {
8-
public constructor(path: String) : this(URL(path))
9+
public constructor(path: String) : this(URI(path).toURL())
910
public constructor(file: File) : this(file.toURI().toURL())
1011
}
1112

@@ -47,7 +48,7 @@ internal val importDataSchema =
4748
}
4849
4950
/** Import the type-only data schema from [path]. */
50-
fun importDataSchema(path: String, name: String): Unit = importDataSchema(URL(path), name)
51+
fun importDataSchema(path: String, name: String): Unit = importDataSchema(URI(path).toURL(), name)
5152
5253
/** Import the type-only data schema from [file]. */
5354
fun importDataSchema(file: File, name: String): Unit = importDataSchema(file.toURI().toURL(), name)

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,21 @@ internal const val MEAN_NO_SKIPNAN = "This function is just here for binary comp
9595
internal const val CONVERT_TO = "This to overload will be removed in favor of `asColumn`. $MESSAGE_0_16"
9696
internal const val CONVERT_TO_REPLACE = "this.asColumn(columnConverter)"
9797

98+
internal const val TO_HTML = "This function is replaced by `toHtml()`. $MESSAGE_0_16"
99+
internal const val TO_HTML_REPLACE = "toHtml(configuration, cellRenderer, getFooter)"
100+
101+
internal const val TO_STANDALONE_HTML = "This function is replaced by `toStandaloneHtml()`. $MESSAGE_0_16"
102+
internal const val TO_STANDALONE_HTML_REPLACE = "toStandaloneHtml(configuration, cellRenderer, getFooter)"
103+
104+
internal const val WRITE_HTML = "This function is replaced by `writeHtml()`. $MESSAGE_0_16"
105+
internal const val WRITE_HTML_REPLACE = "writeHtml(destination)"
106+
107+
internal const val CONVERT_TO_URL = "This function is replaced by `convertToUrl()`. $MESSAGE_0_16"
108+
internal const val CONVERT_TO_URL_REPLACE = "convertToUrl()"
109+
110+
internal const val TO_URL = "This function is replaced by `toUrl()`. $MESSAGE_0_16"
111+
internal const val TO_URL_REPLACE = "toUrl()"
112+
98113
// endregion
99114

100115
// region WARNING in 0.16, ERROR in 0.17

0 commit comments

Comments
 (0)