-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #695 from Kotlin/writerside-tables
Introduce OtherSamples.kt to generate tables for writerside docs outside Korro
- Loading branch information
Showing
9 changed files
with
128 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
.../src/test/kotlin/org/jetbrains/kotlinx/dataframe/explainer/SamplesDisplayConfiguration.kt
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...ources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/explainer/SamplesRenderingUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.jetbrains.kotlinx.dataframe.explainer | ||
|
||
import org.jetbrains.kotlinx.dataframe.DataFrame | ||
import org.jetbrains.kotlinx.dataframe.io.DataFrameHtmlData | ||
import org.jetbrains.kotlinx.dataframe.io.DisplayConfiguration | ||
|
||
val SamplesDisplayConfiguration = DisplayConfiguration(enableFallbackStaticTables = false) | ||
|
||
val WritersideStyle = DataFrameHtmlData( | ||
// copy writerside stlyles | ||
style = """ | ||
body { | ||
font-family: "JetBrains Mono",SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace; | ||
} | ||
:root { | ||
color: #19191C; | ||
background-color: #fff; | ||
} | ||
:root[theme="dark"] { | ||
background-color: #19191C; | ||
color: #FFFFFFCC | ||
} | ||
details details { | ||
margin-left: 20px; | ||
} | ||
summary { | ||
padding: 6px; | ||
} | ||
""".trimIndent() | ||
) | ||
|
||
val WritersideFooter: (DataFrame<*>) -> String = { "" } |
25 changes: 25 additions & 0 deletions
25
...rated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/OtherSamples.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.jetbrains.kotlinx.dataframe.samples.api | ||
|
||
import org.jetbrains.kotlinx.dataframe.AnyFrame | ||
import org.jetbrains.kotlinx.dataframe.api.dataFrameOf | ||
import org.jetbrains.kotlinx.dataframe.explainer.WritersideFooter | ||
import org.jetbrains.kotlinx.dataframe.explainer.WritersideStyle | ||
import org.jetbrains.kotlinx.dataframe.io.toStandaloneHTML | ||
import org.junit.Test | ||
import java.io.File | ||
|
||
// To display code together with a table, we can use TransformDataFrameExpressions annotation together with korro | ||
// This class provides an ability to save only a table that can be embedded anywhere in the documentation | ||
class OtherSamples { | ||
@Test | ||
fun extensionPropertiesApi1() { | ||
val df = dataFrameOf("example")(123) | ||
writeTable(df, "extensionPropertiesApi1") | ||
} | ||
|
||
private fun writeTable(df: AnyFrame, name: String) { | ||
val dir = File("../docs/StardustDocs/snippets/manual").also { it.mkdirs() } | ||
val html = df.toStandaloneHTML(getFooter = WritersideFooter) + WritersideStyle | ||
html.writeHTML(File(dir, "$name.html")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
.../src/test/kotlin/org/jetbrains/kotlinx/dataframe/explainer/SamplesDisplayConfiguration.kt
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/explainer/SamplesRenderingUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.jetbrains.kotlinx.dataframe.explainer | ||
|
||
import org.jetbrains.kotlinx.dataframe.DataFrame | ||
import org.jetbrains.kotlinx.dataframe.io.DataFrameHtmlData | ||
import org.jetbrains.kotlinx.dataframe.io.DisplayConfiguration | ||
|
||
val SamplesDisplayConfiguration = DisplayConfiguration(enableFallbackStaticTables = false) | ||
|
||
val WritersideStyle = DataFrameHtmlData( | ||
// copy writerside stlyles | ||
style = """ | ||
body { | ||
font-family: "JetBrains Mono",SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace; | ||
} | ||
:root { | ||
color: #19191C; | ||
background-color: #fff; | ||
} | ||
:root[theme="dark"] { | ||
background-color: #19191C; | ||
color: #FFFFFFCC | ||
} | ||
details details { | ||
margin-left: 20px; | ||
} | ||
summary { | ||
padding: 6px; | ||
} | ||
""".trimIndent() | ||
) | ||
|
||
val WritersideFooter: (DataFrame<*>) -> String = { "" } |
25 changes: 25 additions & 0 deletions
25
core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/OtherSamples.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.jetbrains.kotlinx.dataframe.samples.api | ||
|
||
import org.jetbrains.kotlinx.dataframe.AnyFrame | ||
import org.jetbrains.kotlinx.dataframe.api.dataFrameOf | ||
import org.jetbrains.kotlinx.dataframe.explainer.WritersideFooter | ||
import org.jetbrains.kotlinx.dataframe.explainer.WritersideStyle | ||
import org.jetbrains.kotlinx.dataframe.io.toStandaloneHTML | ||
import org.junit.Test | ||
import java.io.File | ||
|
||
// To display code together with a table, we can use TransformDataFrameExpressions annotation together with korro | ||
// This class provides an ability to save only a table that can be embedded anywhere in the documentation | ||
class OtherSamples { | ||
@Test | ||
fun extensionPropertiesApi1() { | ||
val df = dataFrameOf("example")(123) | ||
writeTable(df, "extensionPropertiesApi1") | ||
} | ||
|
||
private fun writeTable(df: AnyFrame, name: String) { | ||
val dir = File("../docs/StardustDocs/snippets/manual").also { it.mkdirs() } | ||
val html = df.toStandaloneHTML(getFooter = WritersideFooter) + WritersideStyle | ||
html.writeHTML(File(dir, "$name.html")) | ||
} | ||
} |