Skip to content

Commit 449eb96

Browse files
committed
Add kdoc about "Open in browser" from IDEA that helps to streamline working with HTML rendering
1 parent 8d59c97 commit 449eb96

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

core/api/core.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10347,6 +10347,7 @@ public final class org/jetbrains/kotlinx/dataframe/io/DataFrameHtmlData {
1034710347
public fun toString ()Ljava/lang/String;
1034810348
public final fun withTableDefinitions ()Lorg/jetbrains/kotlinx/dataframe/io/DataFrameHtmlData;
1034910349
public final fun writeHTML (Ljava/io/File;)V
10350+
public final fun writeHTML (Ljava/lang/String;)V
1035010351
public final fun writeHTML (Ljava/nio/file/Path;)V
1035110352
}
1035210353

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,11 @@ internal fun DataFrameHtmlData.print() = println(this)
518518
/**
519519
* By default, cell content is formatted as text
520520
* Use [RenderedContent.media] or [IMG], [IFRAME] if you need custom HTML inside a cell.
521-
* @return DataFrameHtmlData with table script and css definitions. Can be saved as an *.html file and displayed in the browser
521+
*
522+
* [DataFrameHtmlData] be saved as an *.html file and displayed in the browser.
523+
* If you save it as a file and find it in the project tree,
524+
* ["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 file content when it's updated
525+
* @return DataFrameHtmlData with table script and css definitions
522526
*/
523527
public fun <T> DataFrame<T>.toStandaloneHTML(
524528
configuration: DisplayConfiguration = DisplayConfiguration.DEFAULT,
@@ -620,10 +624,18 @@ public data class DataFrameHtmlData(
620624
destination.writeText(toString())
621625
}
622626

627+
public fun writeHTML(destination: String) {
628+
File(destination).writeText(toString())
629+
}
630+
623631
public fun writeHTML(destination: Path) {
624632
destination.writeText(toString())
625633
}
626634

635+
/**
636+
* Opens a new tab in your default browser.
637+
* Consider [writeHTML] with [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
638+
*/
627639
public fun openInBrowser() {
628640
val file = File.createTempFile("df_rendering", ".html")
629641
writeHTML(file)

0 commit comments

Comments
 (0)