Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/java/ch/njol/skript/SkriptCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,9 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
outputDir.mkdirs();

Skript.info(sender, "Generating docs...");
JSONGenerator jsonGenerator = new JSONGenerator(templateDir, outputDir);
jsonGenerator.generate();

JSONGenerator.of(Skript.instance())
.generate(outputDir.toPath().resolve("docs.json"));

if (!templateDir.exists()) {
Skript.info(sender, "JSON-only documentation generated!");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package ch.njol.skript.doc;

import java.io.File;
import java.nio.file.Path;

/**
* Represents a class which generates a documentation format (like HTML or JSON)
* @deprecated Use {@link JSONGenerator} instead.
*/
@Deprecated(forRemoval = true, since = "INSERT VERSION")
public abstract class DocumentationGenerator {

protected File templateDir;
Expand All @@ -16,8 +18,9 @@ public DocumentationGenerator(File templateDir, File outputDir) {
}

/**
* Generates the documentation file
* Use {@link JSONGenerator#generate(Path)} instead.
*/
@Deprecated(forRemoval = true, since = "INSERT VERSION")
public abstract void generate();

}
14 changes: 12 additions & 2 deletions src/main/java/ch/njol/skript/doc/DocumentationIdProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import ch.njol.skript.lang.function.Functions;
import ch.njol.skript.registrations.Classes;
import org.skriptlang.skript.lang.structure.Structure;
import org.skriptlang.skript.registration.SyntaxInfo;

import java.util.Arrays;
import java.util.Iterator;
Expand Down Expand Up @@ -62,7 +63,16 @@ private static <T> int calculateCollisionCount(Iterator<? extends T> potentialCo
* @return the ID of the syntax element
*/
public static <T> String getId(SyntaxElementInfo<? extends T> syntaxInfo) {
Class<?> syntaxClass = syntaxInfo.getElementClass();
return getId((SyntaxInfo<?>) syntaxInfo);
}

/**
* Gets the documentation ID of a syntax element
* @param syntaxInfo the SyntaxInfo to get the ID of
* @return the ID of the syntax element
*/
public static <T> String getId(SyntaxInfo<? extends T> syntaxInfo) {
Class<?> syntaxClass = syntaxInfo.type();
Iterator<? extends SyntaxElementInfo<?>> syntaxElementIterator;
if (Effect.class.isAssignableFrom(syntaxClass)) {
syntaxElementIterator = Skript.getEffects().iterator();
Expand All @@ -79,7 +89,7 @@ public static <T> String getId(SyntaxElementInfo<? extends T> syntaxInfo) {
}
int collisionCount = calculateCollisionCount(syntaxElementIterator,
elementInfo -> elementInfo.getElementClass() == syntaxClass,
elementInfo -> Arrays.equals(elementInfo.getPatterns(), syntaxInfo.getPatterns()));
elementInfo -> Arrays.equals(elementInfo.getPatterns(), syntaxInfo.patterns().toArray(new String[0])));
DocumentationId documentationIdAnnotation = syntaxClass.getAnnotation(DocumentationId.class);
if (documentationIdAnnotation == null) {
return addCollisionSuffix(syntaxClass.getSimpleName(), collisionCount);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/ch/njol/skript/doc/HTMLGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
/**
* Template engine, primarily used for generating Skript documentation
* pages by combining data from annotations and templates.
*
*/
public class HTMLGenerator extends DocumentationGenerator {

Expand Down
Loading
Loading