From 5b4a78bc8970bee1905c3270a7d3d2544e440777 Mon Sep 17 00:00:00 2001 From: Abe Pazos Date: Sat, 30 Aug 2025 14:04:11 +0200 Subject: [PATCH] collectScreenshots: improve comment grabbing algorithm Instead of taking the first block comment, take the last block comment before fun main. There was one case with a commented function above main. --- buildSrc/src/main/kotlin/CollectScreenShots.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/CollectScreenShots.kt b/buildSrc/src/main/kotlin/CollectScreenShots.kt index 7eb17dbb..e4cbea24 100644 --- a/buildSrc/src/main/kotlin/CollectScreenShots.kt +++ b/buildSrc/src/main/kotlin/CollectScreenShots.kt @@ -130,9 +130,10 @@ abstract class CollectScreenshotsTask @Inject constructor() : DefaultTask() { val description = if (ktFile.isFile) { val codeLines = ktFile.readLines() - val start = codeLines.indexOfFirst { it.startsWith("/**") } - val end = codeLines.indexOfFirst { it.endsWith("*/") } val main = codeLines.indexOfFirst { it.startsWith("fun main") } + val head = codeLines.take(main) + val start = head.indexOfLast { it.startsWith("/**") } + val end = head.indexOfLast { it.endsWith("*/") } if ((start < end) && (end < main)) { codeLines.subList(start + 1, end).joinToString("\n") { line ->