From 20849b4a11b76a1836d268271ea718c02af419bb Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Mon, 2 Apr 2018 10:42:02 +0100 Subject: [PATCH] Improve CraftTweaker documentation --- build.gradle | 30 +++++++++++++++++++ .../compat/crafttweaker/CTAlloySmelter.java | 2 ++ .../crafttweaker/CTAssemblingMachine.java | 2 ++ .../compat/crafttweaker/CTBlastFurnace.java | 2 ++ .../compat/crafttweaker/CTCentrifuge.java | 2 ++ .../crafttweaker/CTChemicalReactor.java | 2 ++ .../compat/crafttweaker/CTCompressor.java | 2 ++ .../crafttweaker/CTDistillationTower.java | 2 ++ .../compat/crafttweaker/CTExtractor.java | 2 ++ .../compat/crafttweaker/CTFluidGen.java | 5 ++++ .../compat/crafttweaker/CTFusionReactor.java | 3 ++ .../compat/crafttweaker/CTGrinder.java | 2 ++ .../crafttweaker/CTImplosionCompressor.java | 2 ++ .../CTIndustrialElectrolyzer.java | 2 ++ .../crafttweaker/CTIndustrialGrinder.java | 2 ++ .../crafttweaker/CTIndustrialSawmill.java | 2 ++ .../compat/crafttweaker/CTRollingMachine.java | 1 + .../compat/crafttweaker/CTScrapbox.java | 2 ++ .../compat/crafttweaker/CTVacuumFreezer.java | 2 ++ .../compat/crafttweaker/RecipeSettings.java | 1 + 20 files changed, 70 insertions(+) diff --git a/build.gradle b/build.gradle index aa46f5442..8f2588848 100644 --- a/build.gradle +++ b/build.gradle @@ -295,6 +295,7 @@ build.dependsOn signJar apply from: 'https://github.com/FabricMC/fabric-docs/raw/master/gradle/ideconfig.gradle' +import com.google.gson.JsonArray import groovy.util.XmlSlurper import org.apache.commons.io.FileUtils @@ -356,6 +357,9 @@ task mtDocGen { for(annotation in annoations.toList()){ if(annotation.asJsonObject.get("type").asString.equals("METHOD") && annotation.asJsonObject.get("name").asString.equals("Lstanhebben/zenscript/annotations/ZenMethod;")){ def method = sanitsiseMethodName(annotation.asJsonObject.get("target").asString) + if(hasZenDoc(annotation, annoations)){ + method = getZenDoc(annotation, annoations) + } def zen_name = getZenMetName(clzz) builder.append(zen_name + "." + method) builder.append("\n") @@ -371,6 +375,32 @@ task mtDocGen { } } +boolean hasZenDoc(JsonObject currentAnnotation, JsonArray annoations){ + for(annotation in annoations.toList()){ + if(annotation.asJsonObject.get("target").asString.equals(currentAnnotation.get("target").asString) && annotation.asJsonObject.get("name").asString.equals("Ltechreborn/compat/crafttweaker/ZenDocumentation;")){ + return true + } + } + return false +} + +String getZenDoc(JsonObject currentAnnotation, JsonArray annoations){ + for(annotation in annoations.toList()){ + if(annotation.asJsonObject.get("target").asString.equals(currentAnnotation.get("target").asString) && annotation.asJsonObject.get("name").asString.equals("Ltechreborn/compat/crafttweaker/ZenDocumentation;")){ + def methodName = annotation.asJsonObject.get("target").asString.split("\\(")[0] + def methodParams = annotation.asJsonObject.get("value").asJsonObject.get("value").asString + if(!methodParams.startsWith("(")){ + methodParams = "(" + methodParams + } + if(!methodParams.endsWith(")")){ + methodParams = methodParams + ")" + } + return methodName + methodParams + } + } + return "" +} + //Gets the zenMethod class name from the class json object String getZenMetName(JsonObject jsonObject){ def annoations = jsonObject.get("annotations").asJsonArray diff --git a/src/main/java/techreborn/compat/crafttweaker/CTAlloySmelter.java b/src/main/java/techreborn/compat/crafttweaker/CTAlloySmelter.java index 4cbfa56c8..93aa0c5af 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTAlloySmelter.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTAlloySmelter.java @@ -53,11 +53,13 @@ public class CTAlloySmelter extends CTGeneric { } @ZenMethod + @ZenDocumentation("IIngredient iIngredient") public static void removeInputRecipe(IIngredient iIngredient) { CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName())); } @ZenMethod + @ZenDocumentation("IItemStack output") public static void removeRecipe(IItemStack output) { CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName())); } diff --git a/src/main/java/techreborn/compat/crafttweaker/CTAssemblingMachine.java b/src/main/java/techreborn/compat/crafttweaker/CTAssemblingMachine.java index 304240036..325664938 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTAssemblingMachine.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTAssemblingMachine.java @@ -48,11 +48,13 @@ public class CTAssemblingMachine extends CTGeneric { } @ZenMethod + @ZenDocumentation("IIngredient iIngredient") public static void removeInputRecipe(IIngredient iIngredient) { CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName())); } @ZenMethod + @ZenDocumentation("IItemStack output") public static void removeRecipe(IItemStack output) { CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName())); } diff --git a/src/main/java/techreborn/compat/crafttweaker/CTBlastFurnace.java b/src/main/java/techreborn/compat/crafttweaker/CTBlastFurnace.java index 000ecefd7..7db8c546c 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTBlastFurnace.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTBlastFurnace.java @@ -48,11 +48,13 @@ public class CTBlastFurnace extends CTGeneric { } @ZenMethod + @ZenDocumentation("IIngredient iIngredient") public static void removeInputRecipe(IIngredient iIngredient) { CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName())); } @ZenMethod + @ZenDocumentation("IItemStack output") public static void removeRecipe(IItemStack output) { CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName())); } diff --git a/src/main/java/techreborn/compat/crafttweaker/CTCentrifuge.java b/src/main/java/techreborn/compat/crafttweaker/CTCentrifuge.java index 7d7d8db23..a0f807eca 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTCentrifuge.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTCentrifuge.java @@ -48,11 +48,13 @@ public class CTCentrifuge extends CTGeneric { } @ZenMethod + @ZenDocumentation("IIngredient iIngredient") public static void removeInputRecipe(IIngredient iIngredient) { CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName())); } @ZenMethod + @ZenDocumentation("IItemStack output") public static void removeRecipe(IItemStack output) { CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName())); } diff --git a/src/main/java/techreborn/compat/crafttweaker/CTChemicalReactor.java b/src/main/java/techreborn/compat/crafttweaker/CTChemicalReactor.java index 1130a4a80..ec34b45f3 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTChemicalReactor.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTChemicalReactor.java @@ -48,11 +48,13 @@ public class CTChemicalReactor extends CTGeneric { } @ZenMethod + @ZenDocumentation("IIngredient iIngredient") public static void removeInputRecipe(IIngredient iIngredient) { CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName())); } @ZenMethod + @ZenDocumentation("IItemStack output") public static void removeRecipe(IItemStack output) { CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName())); } diff --git a/src/main/java/techreborn/compat/crafttweaker/CTCompressor.java b/src/main/java/techreborn/compat/crafttweaker/CTCompressor.java index 49bf31d41..323917c9a 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTCompressor.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTCompressor.java @@ -49,11 +49,13 @@ public class CTCompressor extends CTGeneric { } @ZenMethod + @ZenDocumentation("IIngredient iIngredient") public static void removeInputRecipe(IIngredient iIngredient) { CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName())); } @ZenMethod + @ZenDocumentation("IItemStack output") public static void removeRecipe(IItemStack output) { CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName())); } diff --git a/src/main/java/techreborn/compat/crafttweaker/CTDistillationTower.java b/src/main/java/techreborn/compat/crafttweaker/CTDistillationTower.java index 3fd18a792..a09b5d483 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTDistillationTower.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTDistillationTower.java @@ -52,11 +52,13 @@ public class CTDistillationTower extends CTGeneric { } @ZenMethod + @ZenDocumentation("IIngredient iIngredient") public static void removeInputRecipe(IIngredient iIngredient) { CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName())); } @ZenMethod + @ZenDocumentation("IItemStack output") public static void removeRecipe(IItemStack output) { CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName())); } diff --git a/src/main/java/techreborn/compat/crafttweaker/CTExtractor.java b/src/main/java/techreborn/compat/crafttweaker/CTExtractor.java index 9a1e5f446..844966de9 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTExtractor.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTExtractor.java @@ -49,11 +49,13 @@ public class CTExtractor extends CTGeneric { } @ZenMethod + @ZenDocumentation("IIngredient iIngredient") public static void removeInputRecipe(IIngredient iIngredient) { CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName())); } @ZenMethod + @ZenDocumentation("IItemStack output") public static void removeRecipe(IItemStack output) { CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName())); } diff --git a/src/main/java/techreborn/compat/crafttweaker/CTFluidGen.java b/src/main/java/techreborn/compat/crafttweaker/CTFluidGen.java index 194f2dd80..872854f2e 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTFluidGen.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTFluidGen.java @@ -64,26 +64,31 @@ public class CTFluidGen { } @ZenMethod + @ZenDocumentation("ILiquidStack fluid") public static void removeThermalFluid(ILiquidStack fluid) { removeFluid(EFluidGenerator.THERMAL, fluid); } @ZenMethod + @ZenDocumentation("ILiquidStack fluid") public static void removeGasFluid(ILiquidStack fluid) { removeFluid(EFluidGenerator.GAS, fluid); } @ZenMethod + @ZenDocumentation("ILiquidStack fluid") public static void removeSemiFluid(ILiquidStack fluid) { removeFluid(EFluidGenerator.SEMIFLUID, fluid); } @ZenMethod + @ZenDocumentation("ILiquidStack fluid") public static void removeDieselFluid(ILiquidStack fluid) { removeFluid(EFluidGenerator.DIESEL, fluid); } @ZenMethod + @ZenDocumentation("ILiquidStack fluid") public static void removePlasmaFluid(ILiquidStack fluid) { removeFluid(EFluidGenerator.PLASMA, fluid); } diff --git a/src/main/java/techreborn/compat/crafttweaker/CTFusionReactor.java b/src/main/java/techreborn/compat/crafttweaker/CTFusionReactor.java index ade5ba389..33b64f911 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTFusionReactor.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTFusionReactor.java @@ -50,16 +50,19 @@ public class CTFusionReactor { } @ZenMethod + @ZenDocumentation("IIngredient iIngredient") public static void removeTopInputRecipe(IIngredient iIngredient) { CraftTweakerAPI.apply(new RemoveTopInput(iIngredient)); } @ZenMethod + @ZenDocumentation("IIngredient iIngredient") public static void removeBottomInputRecipe(IIngredient iIngredient) { CraftTweakerAPI.apply(new RemoveBottomInput(iIngredient)); } @ZenMethod + @ZenDocumentation("IItemStack output") public static void removeRecipe(IItemStack output) { CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output))); } diff --git a/src/main/java/techreborn/compat/crafttweaker/CTGrinder.java b/src/main/java/techreborn/compat/crafttweaker/CTGrinder.java index 2399a378a..a0bc31d63 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTGrinder.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTGrinder.java @@ -50,11 +50,13 @@ public class CTGrinder extends CTGeneric { } @ZenMethod + @ZenDocumentation("IIngredient iIngredient") public static void removeInputRecipe(IIngredient iIngredient) { CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName())); } @ZenMethod + @ZenDocumentation("IItemStack output") public static void removeRecipe(IItemStack output) { CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName())); } diff --git a/src/main/java/techreborn/compat/crafttweaker/CTImplosionCompressor.java b/src/main/java/techreborn/compat/crafttweaker/CTImplosionCompressor.java index 5f288b6fe..2a8acf16c 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTImplosionCompressor.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTImplosionCompressor.java @@ -48,11 +48,13 @@ public class CTImplosionCompressor extends CTGeneric { } @ZenMethod + @ZenDocumentation("IIngredient iIngredient") public static void removeInputRecipe(IIngredient iIngredient) { CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName())); } @ZenMethod + @ZenDocumentation("IItemStack output") public static void removeRecipe(IItemStack output) { CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName())); } diff --git a/src/main/java/techreborn/compat/crafttweaker/CTIndustrialElectrolyzer.java b/src/main/java/techreborn/compat/crafttweaker/CTIndustrialElectrolyzer.java index 5e5a1f647..47c6691f2 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTIndustrialElectrolyzer.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTIndustrialElectrolyzer.java @@ -48,11 +48,13 @@ public class CTIndustrialElectrolyzer extends CTGeneric { } @ZenMethod + @ZenDocumentation("IIngredient iIngredient") public static void removeInputRecipe(IIngredient iIngredient) { CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName())); } @ZenMethod + @ZenDocumentation("IItemStack output") public static void removeRecipe(IItemStack output) { CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName())); } diff --git a/src/main/java/techreborn/compat/crafttweaker/CTIndustrialGrinder.java b/src/main/java/techreborn/compat/crafttweaker/CTIndustrialGrinder.java index 0265b3d90..a41b8aafe 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTIndustrialGrinder.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTIndustrialGrinder.java @@ -92,6 +92,7 @@ public class CTIndustrialGrinder extends CTGeneric { * @param iIngredient Recipe input for which we should remove recipe */ @ZenMethod + @ZenDocumentation("IIngredient iIngredient") public static void removeInputRecipe(IIngredient iIngredient) { CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName())); } /** @@ -99,6 +100,7 @@ public class CTIndustrialGrinder extends CTGeneric { * @param output Recipe output for which we should remove recipe */ @ZenMethod + @ZenDocumentation("IItemStack output") public static void removeRecipe(IItemStack output) { CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName())); } diff --git a/src/main/java/techreborn/compat/crafttweaker/CTIndustrialSawmill.java b/src/main/java/techreborn/compat/crafttweaker/CTIndustrialSawmill.java index bec9455e1..8d0ff68cc 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTIndustrialSawmill.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTIndustrialSawmill.java @@ -72,11 +72,13 @@ public class CTIndustrialSawmill extends CTGeneric { } @ZenMethod + @ZenDocumentation("IIngredient iIngredient") public static void removeInputRecipe(IIngredient iIngredient) { CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName())); } @ZenMethod + @ZenDocumentation("IItemStack output") public static void removeRecipe(IItemStack output) { CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName())); } diff --git a/src/main/java/techreborn/compat/crafttweaker/CTRollingMachine.java b/src/main/java/techreborn/compat/crafttweaker/CTRollingMachine.java index 2a207eee6..3985acc0f 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTRollingMachine.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTRollingMachine.java @@ -58,6 +58,7 @@ public class CTRollingMachine { } @ZenMethod + @ZenDocumentation("IItemStack output") public static void removeRecipe(IItemStack output) { List toRemove = new ArrayList<>(); for (Map.Entry recipe : RollingMachineRecipe.instance.getRecipeList().entrySet()) { diff --git a/src/main/java/techreborn/compat/crafttweaker/CTScrapbox.java b/src/main/java/techreborn/compat/crafttweaker/CTScrapbox.java index 566cc29ac..cd03e286d 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTScrapbox.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTScrapbox.java @@ -43,11 +43,13 @@ import techreborn.compat.crafttweaker.CTGeneric.Remove; public class CTScrapbox { @ZenMethod + @ZenDocumentation("IIngredient input") public static void addScrapboxDrop(IIngredient input) { RecipeHandler.addRecipe(new ScrapboxRecipe(CraftTweakerMC.getItemStack(input), 20, 2)); } @ZenMethod + @ZenDocumentation("IItemStack output") public static void removeRecipe(IItemStack output) { CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName())); } diff --git a/src/main/java/techreborn/compat/crafttweaker/CTVacuumFreezer.java b/src/main/java/techreborn/compat/crafttweaker/CTVacuumFreezer.java index 1d540c3f4..c77e6712d 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTVacuumFreezer.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTVacuumFreezer.java @@ -46,11 +46,13 @@ public class CTVacuumFreezer extends CTGeneric { } @ZenMethod + @ZenDocumentation("IIngredient iIngredient") public static void removeInputRecipe(IIngredient iIngredient) { CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName())); } @ZenMethod + @ZenDocumentation("IItemStack output") public static void removeRecipe(IItemStack output) { CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName())); } diff --git a/src/main/java/techreborn/compat/crafttweaker/RecipeSettings.java b/src/main/java/techreborn/compat/crafttweaker/RecipeSettings.java index b4ba07aec..d90fb5de6 100644 --- a/src/main/java/techreborn/compat/crafttweaker/RecipeSettings.java +++ b/src/main/java/techreborn/compat/crafttweaker/RecipeSettings.java @@ -14,6 +14,7 @@ public class RecipeSettings { } @ZenMethod + @ZenDocumentation("boolean useOreDict") public void setUseOreDict(boolean useOreDict){ baseRecipe.setOreDict(useOreDict); }