Skip to content

Commit a384ad0

Browse files
committed
updating toStandaloneHtml and toHtml kdocs with more detailed information
1 parent f8201e2 commit a384ad0

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,14 +758,18 @@ public typealias CellFormatter<C> = FormattingDsl.(cell: C) -> CellAttributes?
758758
*
759759
* Call [toHtml] or [toStandaloneHtml] to get the HTML representation of the [DataFrame].
760760
*
761+
* In Jupyter kernel (Kotlin Notebook) environments, you can often output this class directly.
762+
* Use [toHtml] or [toStandaloneHtml] when this produces unexpected results.
763+
*
761764
* You can apply further formatting to this [FormattedFrame] by calling [format()][FormattedFrame.format] once again.
762765
*/
763766
public class FormattedFrame<T>(internal val df: DataFrame<T>, internal val formatter: RowColFormatter<T, *>? = null) {
764767

765768
/**
766769
* Returns a [DataFrameHtmlData] without additional definitions.
767-
* Can be rendered in Jupyter kernel (Notebook) environments or other environments that already have
770+
* Can be rendered in Jupyter kernel (Kotlin Notebook) environments or other environments that already have
768771
* CSS- and script definitions for DataFrame.
772+
*
769773
* Use [toStandaloneHtml] if you need the [DataFrameHtmlData] to include CSS- and script definitions.
770774
*
771775
* By default, cell content is formatted as text
@@ -781,6 +785,8 @@ public class FormattedFrame<T>(internal val df: DataFrame<T>, internal val forma
781785
/**
782786
* Returns a [DataFrameHtmlData] with CSS- and script definitions for DataFrame.
783787
*
788+
* Use [toHtml] if you don't need the [DataFrameHtmlData] to include CSS- and script definitions.
789+
*
784790
* The [DataFrameHtmlData] can be saved as an *.html file and displayed in the browser.
785791
* If you save it as a file and find it in the project tree,
786792
* the ["Open in browser"](https://www.jetbrains.com/help/idea/editing-html-files.html#ws_html_preview_output_procedure)
@@ -789,6 +795,10 @@ public class FormattedFrame<T>(internal val df: DataFrame<T>, internal val forma
789795
* By default, cell content is formatted as text
790796
* Use [RenderedContent.media][media] or [IMG], [IFRAME] if you need custom HTML inside a cell.
791797
*
798+
* __NOTE:__ In Kotlin Notebook, output [FormattedFrame] directly, or use [toHtml],
799+
* as that environment already has CSS- and script definitions for DataFrame.
800+
* Using [toStandaloneHtml] might produce unexpected results.
801+
*
792802
* @param [configuration] The [DisplayConfiguration] to use as a base for this [FormattedFrame].
793803
* Default: [DisplayConfiguration.DEFAULT].
794804
* @see toHtml

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

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -559,17 +559,30 @@ public fun <T> DataFrame<T>.toStandaloneHTML(
559559
): DataFrameHtmlData = toStandaloneHtml(configuration, cellRenderer, getFooter)
560560

561561
/**
562-
* By default, cell content is formatted as text
563-
* Use [RenderedContent.media] or [IMG], [IFRAME] if you need custom HTML inside a cell.
562+
* Returns a [DataFrameHtmlData] with CSS- and script definitions for DataFrame.
564563
*
565564
* To change the formatting of certain cells or columns in the dataframe,
566565
* use [DataFrame.format].
567566
*
567+
* Use [toHtml] if you don't need the [DataFrameHtmlData] to include CSS- and script definitions.
568+
*
568569
* The [DataFrameHtmlData] can be saved as an *.html file and displayed in the browser.
569570
* If you save it as a file and find it in the project tree,
570571
* the ["Open in browser"](https://www.jetbrains.com/help/idea/editing-html-files.html#ws_html_preview_output_procedure)
571572
* feature of IntelliJ IDEA will automatically reload the file content when it's updated.
572-
* @return DataFrameHtmlData with table script and css definitions
573+
*
574+
* By default, cell content is formatted as text
575+
* Use [RenderedContent.media] or [IMG], [IFRAME] if you need custom HTML inside a cell.
576+
*
577+
* __NOTE:__ In Kotlin Notebook, output [DataFrame] directly, or use [toHtml],
578+
* as that environment already has CSS- and script definitions for DataFrame.
579+
* Using [toStandaloneHtml] might produce unexpected results.
580+
*
581+
* @param [configuration] The [DisplayConfiguration] to use. Default: [DisplayConfiguration.DEFAULT].
582+
* @param [cellRenderer] Mostly for internal usage, use [DefaultCellRenderer] if unsure.
583+
* @param [getFooter] Allows you to specify how to render the footer text beneath the dataframe.
584+
* Default: `"DataFrame [rows x cols]"`
585+
* @see toHtml
573586
*/
574587
public fun <T> DataFrame<T>.toStandaloneHtml(
575588
configuration: DisplayConfiguration = DisplayConfiguration.DEFAULT,
@@ -578,13 +591,23 @@ public fun <T> DataFrame<T>.toStandaloneHtml(
578591
): DataFrameHtmlData = toHtml(configuration, cellRenderer, getFooter).withTableDefinitions()
579592

580593
/**
581-
* By default, cell content is formatted as text
582-
* Use [RenderedContent.media] or [IMG], [IFRAME] if you need custom HTML inside a cell.
594+
* Returns a [DataFrameHtmlData] without additional definitions.
595+
* Can be rendered in Jupyter kernel (Kotlin Notebook) environments or other environments that already have
596+
* CSS- and script definitions for DataFrame.
583597
*
584598
* To change the formatting of certain cells or columns in the dataframe,
585599
* use [DataFrame.format].
586600
*
587-
* @return DataFrameHtmlData without additional definitions. Can be rendered in Jupyter kernel environments
601+
* Use [toStandaloneHtml] if you need the [DataFrameHtmlData] to include CSS- and script definitions.
602+
*
603+
* By default, cell content is formatted as text
604+
* Use [RenderedContent.media] or [IMG], [IFRAME] if you need custom HTML inside a cell.
605+
*
606+
* @param [configuration] The [DisplayConfiguration] to use. Default: [DisplayConfiguration.DEFAULT].
607+
* @param [cellRenderer] Mostly for internal usage, use [DefaultCellRenderer] if unsure.
608+
* @param [getFooter] Allows you to specify how to render the footer text beneath the dataframe.
609+
* Default: `"DataFrame [rows x cols]"`
610+
* @see toStandaloneHtml
588611
*/
589612
public fun <T> DataFrame<T>.toHtml(
590613
configuration: DisplayConfiguration = DisplayConfiguration.DEFAULT,

0 commit comments

Comments
 (0)