Skip to content

Commit 7e839d6

Browse files
committed
Continuing format docs for the website, using new sample dataframes in the tests module. Updated references to format
1 parent e92a8f6 commit 7e839d6

File tree

14 files changed

+1349
-325
lines changed

14 files changed

+1349
-325
lines changed

core/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ and [tests/.../samples/api](../tests/src/test/kotlin/org/jetbrains/kotlinx/dataf
1818
and they are copied over to Markdown files in [docs/StardustDocs/topics](../docs/StardustDocs/topics)
1919
by [Korro](https://github.com/devcrocod/korro).
2020

21-
### Explainer dataframes
21+
### ~~Explainer dataframes~~ NOTE: This is being moved to [tests](../tests)
2222

2323
Aside from code samples, `@TransformDataFrameExpressions` annotated test functions also generate sample
2424
dataframe HTML files that can be used as iFrames on the documentation website.

core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/Modify.kt

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,38 +1309,4 @@ class Modify : TestBase() {
13091309
}
13101310
// SampleEnd
13111311
}
1312-
1313-
@Test
1314-
fun formatExample_properties() {
1315-
// SampleStart
1316-
df
1317-
.format().with { bold and textColor(black) }
1318-
.format { isHappy }.with { background(if (it) green else red) }
1319-
.format { weight }.notNull().linearBg(50 to FormattingDsl.blue, 90 to FormattingDsl.red)
1320-
.format { age }.perRowCol { row, col ->
1321-
textColor(
1322-
linear(value = col[row], from = col.min() to blue, to = col.max() to green)
1323-
)
1324-
}
1325-
.toStandaloneHtml()
1326-
// SampleEnd
1327-
}
1328-
1329-
@Suppress("UNCHECKED_CAST")
1330-
@Test
1331-
fun formatExample_strings() {
1332-
// SampleStart
1333-
df
1334-
.format().with { bold and textColor(black) }
1335-
.format("isHappy").with { background(if (it as Boolean) green else red) }
1336-
.format("weight").notNull().with { linearBg(it as Int, 50 to blue, 90 to red) }
1337-
.format("age").perRowCol { row, col ->
1338-
col as DataColumn<Int>
1339-
textColor(
1340-
linear(value = col[row], from = col.min() to blue, to = col.max() to green)
1341-
)
1342-
}
1343-
.toStandaloneHtml()
1344-
// SampleEnd
1345-
}
13461312
}

core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/OtherSamples.kt

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@ package org.jetbrains.kotlinx.dataframe.samples.api
22

33
import org.jetbrains.kotlinx.dataframe.AnyFrame
44
import org.jetbrains.kotlinx.dataframe.DataFrame
5-
import org.jetbrains.kotlinx.dataframe.api.*
6-
import org.jetbrains.kotlinx.dataframe.api.FormattedFrame
75
import org.jetbrains.kotlinx.dataframe.api.take
86
import org.jetbrains.kotlinx.dataframe.explainer.WritersideFooter
97
import org.jetbrains.kotlinx.dataframe.explainer.WritersideStyle
10-
import org.jetbrains.kotlinx.dataframe.io.DisplayConfiguration
118
import org.jetbrains.kotlinx.dataframe.io.read
129
import org.jetbrains.kotlinx.dataframe.io.toStandaloneHtml
1310
import org.junit.Test
1411
import java.io.File
1512

1613
// To display code together with a table, we can use TransformDataFrameExpressions annotation together with korro
1714
// This class provides an ability to save only a table that can be embedded anywhere in the documentation
15+
16+
@Deprecated("This can now be reproduced with 'sample dataframes' in the 'tests' module.")
1817
class OtherSamples : TestBase() {
1918

2019
@Test
@@ -23,33 +22,9 @@ class OtherSamples : TestBase() {
2322
// writeTable(df, "exampleName")
2423
}
2524

26-
@Test
27-
fun formatExample() {
28-
val formattedDf = df
29-
.format().with { bold and textColor(black) }
30-
.format { isHappy }.with { background(if (it) green else red) }
31-
.format { weight }.notNull().linearBg(50 to FormattingDsl.blue, 90 to FormattingDsl.red)
32-
.format { age }.perRowCol { row, col ->
33-
textColor(
34-
linear(value = col[row], from = col.min() to blue, to = col.max() to green),
35-
)
36-
}
37-
38-
writeTable(formattedDf, "formatExample")
39-
}
40-
4125
private fun writeTable(df: AnyFrame, name: String) {
4226
val dir = File("../docs/StardustDocs/resources/snippets/manual").also { it.mkdirs() }
4327
val html = df.toStandaloneHtml(getFooter = WritersideFooter) + WritersideStyle
4428
html.writeHtml(File(dir, "$name.html"))
4529
}
46-
47-
private fun writeTable(formattedDf: FormattedFrame<*>, name: String) {
48-
val dir = File("../docs/StardustDocs/resources/snippets/manual").also { it.mkdirs() }
49-
val html = formattedDf.df.toStandaloneHtml(
50-
configuration = formattedDf.getDisplayConfiguration(DisplayConfiguration.DEFAULT),
51-
getFooter = WritersideFooter,
52-
) + WritersideStyle
53-
html.writeHtml(File(dir, "$name.html"))
54-
}
5530
}

0 commit comments

Comments
 (0)