From c9542139fa9f12b601a593d8507de3617759d6a0 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Sat, 4 Jan 2025 21:13:04 +0100 Subject: refactor: Generate more doc for item ids --- build.gradle.kts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'build.gradle.kts') diff --git a/build.gradle.kts b/build.gradle.kts index e7d6b0e..84ab31d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,7 @@ import com.github.gmazzo.buildconfig.BuildConfigExtension import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.google.gson.Gson +import com.google.gson.JsonObject import org.apache.commons.lang3.SystemUtils import proguard.gradle.ProGuardTask import java.io.ByteArrayOutputStream @@ -156,7 +157,7 @@ abstract class GenerateItemIds : DefaultTask() { fun generateItemIds() { val nonIdName = "[^A-Z0-9_]".toRegex() - data class Item(val id: String) { + data class Item(val id: String, val file: File) { val javaName get() = id.replace(nonIdName, { "__" + it.value.single().code }) } @@ -166,7 +167,7 @@ abstract class GenerateItemIds : DefaultTask() { if (listFile.extension != "json") { error("Unknown file $listFile") } - items.add(Item(listFile.nameWithoutExtension)) + items.add(Item(listFile.nameWithoutExtension, listFile)) } items.sortedBy { it.id } outputFile.parentFile.mkdirs() @@ -183,7 +184,13 @@ abstract class GenerateItemIds : DefaultTask() { writer.appendLine("public class ItemIds {") val gson = Gson() for (item in items) { + val itemJson = gson.fromJson(item.file.readText(), JsonObject::class.java) writer.appendLine("\t/**") + writer.appendLine("\t * ") + writer.appendLine("\t * ") + writer.appendLine("\t * ") + writer.appendLine("\t * ") + writer.appendLine("\t *
Display Name{@code ${itemJson["displayname"].asString}}
Vanilla Item{@code ${itemJson["itemid"].asString}}
Internal Name{@code ${itemJson["internalname"].asString}}
") writer.appendLine("\t * @see JSON definition") writer.appendLine("\t */") writer.appendLine("\tpublic static final ItemId ${item.javaName} =" + -- cgit