Skip to content

Commit 61aeff7

Browse files
committed
add property info itself to related syntaxes docs
1 parent 2bd6f39 commit 61aeff7

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

src/main/java/ch/njol/skript/doc/JSONGenerator.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ private static JsonObject generatedAnnotatedElement(SyntaxElementInfo<?> syntaxI
114114
&& (property = PROPERTY_REGISTRY.get(relatedProperty.value())) != null) {
115115
PROPERTY_RELATED_SYNTAXES.computeIfAbsent(property, key -> new HashSet<>()).add(syntaxInfo);
116116
}
117+
syntaxJsonObject.add("property", property == null ? null : getPropertyDetails(property));
117118
syntaxJsonObject.add("propertyClasses", property == null ? null : getPropertyRelatedClassInfos(property));
118119

119120
if (syntaxClass.isAnnotationPresent(Examples.class)) {
@@ -318,8 +319,8 @@ private static JsonObject generateClassInfoElement(ClassInfo<?> classInfo) {
318319
/**
319320
* Returns a JsonArray containing the properties of a classinfo, with their ids, names, descriptions, and related syntaxes
320321
* Related syntaxes are returned as a list containing their ids and names
321-
* @param classInfo
322-
* @return
322+
* @param classInfo the classinfo to get the properties of
323+
* @return a JsonArray containing the properties of the classinfo with their ids, names, descriptions, and related syntaxes
323324
*/
324325
private static JsonArray getClassInfoProperties(ClassInfo<?> classInfo) {
325326
JsonArray array = new JsonArray();
@@ -391,6 +392,20 @@ private static JsonElement getPropertyRelatedSyntaxes(Property<?> property) {
391392
return array;
392393
}
393394

395+
/**
396+
* Generates the documentation JsonObject for a property
397+
*
398+
* @param property the property to generate the JsonObject of
399+
* @return the JsonObject of the property containing the id, name, and description
400+
*/
401+
private static JsonObject getPropertyDetails(Property<?> property) {
402+
JsonObject object = new JsonObject();
403+
object.addProperty("id", DocumentationIdProvider.getId(property));
404+
object.addProperty("name", property.name());
405+
object.addProperty("description", property.description());
406+
return object;
407+
}
408+
394409
/**
395410
* Generates a JsonArray containing the documentation JsonObjects for each property in the iterator.
396411
* Must be run after all other syntax elements (not including ClassInfos) so that related syntaxes can be found.
@@ -401,10 +416,7 @@ private static JsonElement getPropertyRelatedSyntaxes(Property<?> property) {
401416
private static JsonElement generatePropertiesArray(Iterator<Property<?>> iterator) {
402417
JsonArray array = new JsonArray();
403418
iterator.forEachRemaining(property -> {
404-
JsonObject object = new JsonObject();
405-
object.addProperty("id", DocumentationIdProvider.getId(property));
406-
object.addProperty("name", property.name());
407-
object.addProperty("description", property.description());
419+
JsonObject object = getPropertyDetails(property);
408420
object.add("relatedClasses", getPropertyRelatedClassInfos(property));
409421
object.add("relatedSyntaxes", getPropertyRelatedSyntaxes(property));
410422
array.add(object);

0 commit comments

Comments
 (0)