Skip to content

Commit

Permalink
update: wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
sakurawald committed Jul 16, 2024
1 parent 0d6a00c commit c3e07e0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,16 @@ tasks.modrinth.dependsOn(tasks.modrinthSyncBody)
// test framework
test {
useJUnitPlatform()
filter {
includeTestsMatching 'ConfigDocGenTest.generate'
}
}

tasks.register('generateModuleDocumentation') {
outputs.upToDateWhen { false }
test {
filter {
includeTestsMatching 'ModuleDocumentationGeneratorTest.buildModuleDocumentation'
includeTestsMatching 'ModuleDocGenTest.generate'
}
}
}
Expand All @@ -160,7 +163,7 @@ tasks.register('generateMixinRegistry') {
outputs.upToDateWhen { false }
test {
filter {
includeTestsMatching 'MixinRegistryGeneratorTest.generate'
includeTestsMatching 'MixinRegistryGenTest.generate'
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/github/sakurawald/Fuji.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
// TODO: invsee module
// TODO: condense module
// TODO: powertool modul

// TODO: code review for skin module

// TODO: luckperms context calculator
Expand All @@ -38,6 +37,7 @@
// TODO: a generalized mixin plugin to dispatch text.
// TODO: a friendly mixin pre-checker
// TODO: a program to generate module reference DAG
// TODO: a program to generate config json with documentation

public class Fuji implements ModInitializer {
public static final String MOD_ID = "fuji";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.List;
import java.util.Map;

public class ConfigurationDocumentationGeneratorTest {
public class ConfigDocGenTest {

private JsonObject processJavaObject(Object obj) {
JsonObject jsonObject = new JsonObject();
Expand Down Expand Up @@ -76,22 +76,28 @@ private boolean isPrimitiveOrWrapper(Class<?> clazz) {
return clazz.isPrimitive() || clazz == Boolean.class || clazz == Character.class ||
Number.class.isAssignableFrom(clazz) || clazz == String.class;
}
private String applyRegex(String json) {
// return json.replaceAll("\"\\S+@documentation\":\\s+\"(.+)\",", "# $1");
return json;
}

private void writeToFile(String fileName, JsonObject content) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String filePath = "./build/documentation/" + fileName;
new File(filePath).getParentFile().mkdirs();

try (FileWriter writer = new FileWriter(filePath)) {
writer.write(gson.toJson(content));
String json = gson.toJson(content);
json = applyRegex(json);
writer.write(json);
System.out.println("File " + fileName + " has been written successfully.");
} catch (IOException e) {
System.err.println("An error occurred while writing file: " + e.getMessage());
}
}

@Test
void buildConfigurationDocumentation() {
void generate() {
writeToFile("config.json", processJavaObject(new ConfigModel()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.io.*;
import java.util.Iterator;

public class MixinRegistryGeneratorTest {
public class MixinRegistryGenTest {

@SneakyThrows
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.io.IOException;

@Slf4j
public class ModuleDocumentationGeneratorTest {
public class ModuleDocGenTest {

private StringBuilder processJavaObject(Object obj) {
StringBuilder sb = new StringBuilder();
Expand Down Expand Up @@ -58,7 +58,7 @@ private void writeToFile(String fileName, Object object) {
}

@Test
void buildModuleDocumentation() {
void generate() {
writeToFile("Module.md", processJavaObject(new ConfigModel().modules));
}

Expand Down

0 comments on commit c3e07e0

Please sign in to comment.