Skip to content

Commit 6208e47

Browse files
authored
Merge pull request #324 from Kotlin/documentation-tables
Configure writerside to include tables
2 parents 8b371dc + a19dd96 commit 6208e47

File tree

251 files changed

+80241
-31
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

251 files changed

+80241
-31
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Checkout repository
2525
uses: actions/checkout@v3
2626
- name: Build Writerside docs using Docker
27-
uses: JetBrains/writerside-github-action@v3
27+
uses: ./.github/writerside-build
2828
- name: Upload artifact
2929
uses: actions/upload-artifact@v3
3030
with:

.github/writerside-build/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Container image that runs your code
2+
FROM registry.jetbrains.team/p/writerside/builder/writerside-builder:2.1.1256-p3333
3+
4+
# Copies your code file from your action repository to the filesystem path `/` of the container
5+
COPY entrypoint.sh /entrypoint.sh
6+
7+
RUN chmod +x /entrypoint.sh
8+
9+
# Code file to execute when the docker container starts up (`entrypoint.sh`)
10+
ENTRYPOINT ["/entrypoint.sh"]

.github/writerside-build/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: Build Writerside docs using Docker
2+
description: Build Writerside documentation artifacts
3+
4+
runs:
5+
using: 'docker'
6+
image: 'Dockerfile'
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
set -e
4+
/opt/builder/bin/idea.sh helpbuilderinspect -source-dir . -product $PRODUCT --runner github -output-dir artifacts/ || true
5+
echo "Test existing of $ARTIFACT artifact"
6+
test -e artifacts/$ARTIFACT

core/build.gradle.kts

Lines changed: 81 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import com.google.devtools.ksp.gradle.KspTaskJvm
2+
import com.google.devtools.ksp.gradle.KspTask
23
import nl.jolanrensen.docProcessor.defaultProcessors.*
34
import nl.jolanrensen.docProcessor.gradle.creatingProcessDocTask
45
import org.gradle.jvm.tasks.Jar
@@ -33,9 +34,27 @@ repositories {
3334
maven(jupyterApiTCRepo)
3435
}
3536

37+
kotlin.sourceSets {
38+
main {
39+
kotlin.srcDir("build/generated/ksp/main/kotlin/")
40+
}
41+
test {
42+
kotlin.srcDir("build/generated/ksp/test/kotlin/")
43+
}
44+
}
45+
46+
sourceSets {
47+
create("samples") {
48+
kotlin.srcDir("src/test/kotlin")
49+
}
50+
}
51+
3652
dependencies {
53+
val kotlinCompilerPluginClasspathSamples by configurations.getting
54+
3755
api(libs.kotlin.reflect)
3856
implementation(libs.kotlin.stdlib)
57+
kotlinCompilerPluginClasspathSamples(project(":plugins:expressions-converter"))
3958
implementation(libs.kotlin.stdlib.jdk8)
4059

4160
api(libs.commonsCsv)
@@ -53,13 +72,69 @@ dependencies {
5372
testImplementation(libs.jsoup)
5473
}
5574

56-
kotlin.sourceSets {
57-
main {
58-
kotlin.srcDir("build/generated/ksp/main/kotlin/")
75+
val samplesImplementation by configurations.getting {
76+
extendsFrom(configurations.testImplementation.get())
77+
}
78+
79+
val myKotlinCompileTask = tasks.named<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>("compileSamplesKotlin") {
80+
friendPaths.from(sourceSets["main"].output.classesDirs)
81+
source(sourceSets["test"].kotlin)
82+
destinationDirectory.set(file("$buildDir/classes/testWithOutputs/kotlin"))
83+
}
84+
85+
tasks.withType<KspTask> {
86+
// "test" classpath is re-used, so repeated generation should be disabled
87+
if (name == "kspSamplesKotlin") {
88+
dependsOn("kspTestKotlin")
89+
enabled = false
5990
}
60-
test {
61-
kotlin.srcDir("build/generated/ksp/test/kotlin/")
91+
}
92+
93+
tasks.named("lintKotlinSamples") {
94+
onlyIf { false }
95+
}
96+
97+
val samplesTest = tasks.register<Test>("samplesTest") {
98+
group = "Verification"
99+
description = "Runs the custom tests."
100+
101+
dependsOn(myKotlinCompileTask)
102+
103+
doFirst {
104+
delete {
105+
delete(fileTree(File(buildDir, "dataframes")))
106+
}
107+
}
108+
109+
environment("DATAFRAME_SAVE_OUTPUTS", "")
110+
111+
filter {
112+
includeTestsMatching("org.jetbrains.kotlinx.dataframe.samples.api.*")
62113
}
114+
115+
ignoreFailures = true
116+
117+
testClassesDirs = fileTree("$buildDir/classes/testWithOutputs/kotlin")
118+
classpath = files("$buildDir/classes/testWithOutputs/kotlin") + configurations["samplesRuntimeClasspath"] + sourceSets["main"].runtimeClasspath
119+
}
120+
121+
val clearSamplesOutputs by tasks.creating {
122+
group = "documentation"
123+
124+
doFirst {
125+
delete {
126+
delete(fileTree(File(projectDir, "../docs/StardustDocs/snippets")))
127+
}
128+
}
129+
}
130+
131+
val copySamplesOutputs = tasks.register<JavaExec>("copySamplesOutputs") {
132+
group = "documentation"
133+
mainClass.set("org.jetbrains.kotlinx.dataframe.explainer.SampleAggregatorKt")
134+
135+
dependsOn(samplesTest)
136+
dependsOn(clearSamplesOutputs)
137+
classpath = sourceSets.test.get().runtimeClasspath
63138
}
64139

65140
val generatedSourcesFolderName = "generated-sources"
@@ -175,6 +250,7 @@ kotlinter {
175250
"filename",
176251
"comment-spacing",
177252
"curly-spacing",
253+
"experimental:annotation-spacing"
178254
)
179255
}
180256

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ internal fun tableJs(columns: List<ColumnDataForJs>, id: Int, rootId: Int, nrow:
114114
}
115115

116116
internal var tableInSessionId = 0
117-
internal val sessionId = (Random().nextInt() % 128) shl 24
117+
internal var sessionId = (Random().nextInt() % 128) shl 24
118118
internal fun nextTableId() = sessionId + (tableInSessionId++)
119119

120120
internal fun AnyFrame.toHtmlData(
@@ -217,7 +217,11 @@ public fun <T> DataFrame<T>.toHTML(
217217
* Container for HTML page data in form of String
218218
* Can be used to compose rendered dataframe tables with additional HTML elements
219219
*/
220-
public data class DataFrameHtmlData(val style: String = "", val body: String = "", val script: String = "") {
220+
public data class DataFrameHtmlData(
221+
@Language("css") val style: String = "",
222+
@Language("html", prefix = "<body>", suffix = "</body>") val body: String = "",
223+
@Language("js") val script: String = ""
224+
) {
221225
@Language("html")
222226
override fun toString(): String = """
223227
<html>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ internal fun convertToDataFrame(dataframeLike: Any): AnyFrame =
266266
is PivotGroupBy<*> -> dataframeLike.frames()
267267
is ReducedPivotGroupBy<*> -> dataframeLike.values()
268268
is SplitWithTransform<*, *, *> -> dataframeLike.into()
269+
is Split<*, *> -> dataframeLike.toDataFrame()
269270
is Merge<*, *, *> -> dataframeLike.into("merged")
270271
is Gather<*, *, *, *> -> dataframeLike.into("key", "value")
271272
is Update<*, *> -> dataframeLike.df

0 commit comments

Comments
 (0)