@@ -47,7 +47,6 @@ private fun convertToHTML(dataframeLike: Any): DataFrameHtmlData {
47
47
is SplitWithTransform <* , * , * > -> dataframeLike.into().toHTML()
48
48
is Merge <* , * , * > -> dataframeLike.into(" merged" ).toHTML()
49
49
is Gather <* , * , * , * > -> dataframeLike.into(" key" , " value" ).toHTML()
50
- // is Update<*, *> -> DataFrameHtmlData(body = "<p>${dataframeLike::class}</p>")
51
50
is Update <* , * > -> dataframeLike.df.let {
52
51
var it = it.format(dataframeLike.columns as ColumnsSelectionDsl <Any ?>.(it: ColumnsSelectionDsl <Any ?>) -> ColumnSet <* >)
53
52
if (dataframeLike.filter != null ) {
@@ -98,33 +97,12 @@ private fun convertToDescription(dataframeLike: Any): String {
98
97
is GroupBy <* , * > -> " GroupBy"
99
98
is DataRow <* > -> " DataRow"
100
99
else -> " TODO"
101
- }.escapeHTML ()
100
+ }.escapeHtmlForIFrame ()
102
101
}
103
102
104
103
annotation class TransformDataFrameExpressions
105
104
106
- fun main () {
107
- File (" build/dataframes" )
108
- .walkTopDown()
109
- .filter {
110
- it.nameWithoutExtension.startsWith(" org.jetbrains" )
111
- }
112
- // org.ClassName.functionName_properties
113
- // <dataFrame src="org.jetbrains.kotlinx.dataframe.samples.api.Modify.addDfs.html"/>
114
- .groupBy {
115
- it.nameWithoutExtension.substringBefore(" _" )
116
- }
117
- .mapValues { (name, files) ->
118
- val target = File (" ../docs/StardustDocs/snippets" )
119
- val original = files
120
- .firstOrNull { it.nameWithoutExtension.contains(" properties" ) }
121
- ? : files.first()
122
- original.copyTo(File (target, " $name .html" ), overwrite = true )
123
- }
124
- }
125
-
126
105
object PluginCallback {
127
- // var i = AtomicInteger(0)
128
106
val names = mutableMapOf<String , List <String >>()
129
107
val expressionsByStatement = mutableMapOf<Int , List <Expression >>()
130
108
@@ -140,7 +118,7 @@ object PluginCallback {
140
118
}
141
119
142
120
fun save () {
143
- // if (i.get() == 0) return
121
+ // ensure stable table ids across test invocation
144
122
sessionId = 0
145
123
tableInSessionId = 0
146
124
var output = DataFrameHtmlData .tableDefinitions() + DataFrameHtmlData (
@@ -188,7 +166,7 @@ object PluginCallback {
188
166
.also {
189
167
if (it.length > 95 ) TODO (" expression is too long ${it.length} . better to split sample in multiple snippets" )
190
168
}
191
- .escapeHTML ()} </summary>
169
+ .escapeHtmlForIFrame ()} </summary>
192
170
${details.body}
193
171
</details>
194
172
<br>
@@ -262,7 +240,6 @@ object PluginCallback {
262
240
263
241
var action: (String , String , Any , String , String? , String? , String? , Int ) -> Unit =
264
242
{ source, name, df, id, receiverId, containingClassFqName, containingFunName, statementIndex ->
265
- // i.incrementAndGet()
266
243
expressionsByStatement.compute(statementIndex) { _, list ->
267
244
val element = Expression (source, containingClassFqName, containingFunName, df)
268
245
list?.plus(element) ? : listOf (element)
@@ -304,6 +281,7 @@ object PluginCallback {
304
281
// convertToHTML(df).writeHTML(File("build/dataframes/$path"))
305
282
}
306
283
284
+ @Suppress(" unused" )
307
285
fun doAction (
308
286
string : String ,
309
287
name : String ,
@@ -318,7 +296,7 @@ object PluginCallback {
318
296
}
319
297
}
320
298
321
- internal fun String.escapeHTML (): String {
299
+ internal fun String.escapeHtmlForIFrame (): String {
322
300
val str = this
323
301
return buildString {
324
302
for (c in str) {
@@ -328,12 +306,9 @@ internal fun String.escapeHTML(): String {
328
306
append(c.code)
329
307
append(' ;' )
330
308
}
331
- // c == '<' -> append("<")
332
- // c == '>' -> append(">")
333
309
c == ' "' -> append(" "" )
334
310
c == ' <' -> append(" &lt;" )
335
311
c == ' >' -> append(" &gt;" )
336
- // c == '"' -> append("&quot;")
337
312
c == ' &' -> append(" &" )
338
313
else -> {
339
314
append(c)
0 commit comments