Skip to content

Commit 1399d21

Browse files
Automated commit of generated code
1 parent 8d07b78 commit 1399d21

File tree

4 files changed

+106
-3
lines changed

4 files changed

+106
-3
lines changed

core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/explainer/PluginCallbackProxy.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ object PluginCallbackProxy : PluginCallback {
131131
File(korro, group).writeText(
132132
"""
133133
134-
<dataFrame src="$group.html"/>
134+
<inline-frame src="resources/$group.html" width="100%"/>
135135
""".trimIndent(),
136136
)
137137
}

core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/explainer/SampleAggregator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fun main() {
1313
.groupBy {
1414
it.nameWithoutExtension.substringBefore("_")
1515
}.mapValues { (name, files) ->
16-
val target = File("../docs/StardustDocs/snippets")
16+
val target = File("../docs/StardustDocs/resources/snippets")
1717
val original = files
1818
.firstOrNull { it.nameWithoutExtension.contains("properties") }
1919
?: files.first()

core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/explainer/SamplesRenderingUtils.kt

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,109 @@ val WritersideStyle = DataFrameHtmlData(
3232
padding: 6px;
3333
}
3434
""".trimIndent(),
35+
script =
36+
"""
37+
function sendHeight() {
38+
let totalHeight = 0;
39+
40+
document.querySelectorAll('body > details, body > br').forEach(element => {
41+
if (element.tagName === 'DETAILS') {
42+
totalHeight += getElementHeight(element.querySelector(':scope > summary'));
43+
44+
if (element.open) {
45+
totalHeight += getVisibleContentHeight(element);
46+
}
47+
} else if (element.tagName === 'BR') {
48+
totalHeight += getElementHeight(element);
49+
}
50+
});
51+
52+
totalHeight += 10;
53+
54+
window.parent.postMessage({type: 'iframeHeight', height: Math.ceil(totalHeight)}, '*');
55+
}
56+
57+
function getVisibleContentHeight(detailsElement) {
58+
let height = 0;
59+
60+
detailsElement.querySelectorAll(':scope > details, :scope > table, :scope > p').forEach(child => {
61+
if (child.tagName === 'DETAILS') {
62+
const summary = child.querySelector(':scope > summary');
63+
height += getElementHeight(summary);
64+
65+
if (child.open) {
66+
height += getDirectVisibleContentHeight(child);
67+
}
68+
} else if (isElementVisible(child)) {
69+
height += getElementHeight(child);
70+
}
71+
});
72+
73+
return height;
74+
}
75+
76+
function getDirectVisibleContentHeight(element) {
77+
let height = 0;
78+
element.querySelectorAll(':scope > table, :scope > p, :scope > summary').forEach(child => {
79+
if (isElementVisible(child)) {
80+
height += getElementHeight(child);
81+
}
82+
});
83+
return height;
84+
}
85+
86+
function getElementHeight(el) {
87+
const styles = getComputedStyle(el);
88+
const margin = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
89+
90+
// More reliable cross-browser calculation
91+
const rect = el.getBoundingClientRect();
92+
return rect.height + margin;
93+
}
94+
95+
function isElementVisible(el) {
96+
return !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);
97+
}
98+
99+
function sendInitialHeight() {
100+
let initialHeight = 0;
101+
102+
document.querySelectorAll('body > details, body > br').forEach(element => {
103+
if (element.tagName === 'DETAILS') {
104+
initialHeight += getElementHeight(element.querySelector(':scope > summary'));
105+
} else if (element.tagName === 'BR') {
106+
initialHeight += getElementHeight(element);
107+
}
108+
});
109+
110+
initialHeight += 10;
111+
112+
window.parent.postMessage({type: 'iframeHeight', height: Math.ceil(initialHeight)}, '*');
113+
}
114+
115+
function repeatHeightCalculation(maxRetries = 10, interval = 100) {
116+
let retries = 0;
117+
const intervalId = setInterval(() => {
118+
sendInitialHeight();
119+
retries++;
120+
if (retries >= maxRetries) clearInterval(intervalId);
121+
}, interval);
122+
}
123+
124+
window.addEventListener('load', () => {
125+
repeatHeightCalculation();
126+
127+
128+
document.querySelectorAll('details').forEach(detail => {
129+
detail.addEventListener('toggle', () => {
130+
setTimeout(sendHeight, 50);
131+
});
132+
});
133+
134+
const observer = new MutationObserver(() => setTimeout(sendHeight, 50));
135+
observer.observe(document.body, {childList: true, subtree: true, characterData: true});
136+
});
137+
""".trimIndent(),
35138
)
36139

37140
val WritersideFooter: (DataFrame<*>) -> String = { "" }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class OtherSamples {
2121
}
2222

2323
private fun writeTable(df: AnyFrame, name: String) {
24-
val dir = File("../docs/StardustDocs/snippets/manual").also { it.mkdirs() }
24+
val dir = File("../docs/StardustDocs/resources/snippets/manual").also { it.mkdirs() }
2525
val html = df.toStandaloneHtml(getFooter = WritersideFooter) + WritersideStyle
2626
html.writeHtml(File(dir, "$name.html"))
2727
}

0 commit comments

Comments
 (0)