add AutoDocShadow

This commit is contained in:
dfsek 2021-04-26 23:13:44 -07:00
parent c87d0446d3
commit be3e50411e
3 changed files with 29 additions and 7 deletions

View File

@ -94,6 +94,9 @@ tasks.create<SourceTask>("tectonicDocs") {
if (declaration.isAnnotationPresent("AutoDocAlias")) {
refactor[name] = (declaration.getAnnotationByName("AutoDocAlias").get().childNodes[1] as StringLiteralExpr).asString()
println("Refactoring $name to ${refactor[name]}.")
} else if (declaration.isAnnotationPresent("AutoDocShadow")) {
refactor[name] = (declaration.getAnnotationByName("AutoDocShadow").get().childNodes[1] as StringLiteralExpr).asString()
println("Shadowing $name to ${refactor[name]}.")
}
}
}
@ -101,10 +104,12 @@ tasks.create<SourceTask>("tectonicDocs") {
val children = HashMap<String, MutableList<ClassOrInterfaceDeclaration>>()
sources.forEach { (name, unit) ->
unit.getClassByName(name).ifPresent { declaration ->
declaration.extendedTypes.forEach { classOrInterfaceType ->
val inherit = classOrInterfaceType.name.asString()
if (!children.containsKey(inherit)) children[inherit] = ArrayList()
children[inherit]!!.add(declaration)
if(!declaration.isAnnotationPresent("AutoDocShadow")) {
declaration.extendedTypes.forEach { classOrInterfaceType ->
val inherit = classOrInterfaceType.name.asString()
if (!children.containsKey(inherit)) children[inherit] = ArrayList()
children[inherit]!!.add(declaration)
}
}
}
}
@ -121,7 +126,7 @@ tasks.create<SourceTask>("tectonicDocs") {
unit.getClassByName(name).ifPresent { declaration ->
applicable = scanForParent(sources, declaration, "ConfigTemplate", "ValidatedConfigTemplate", "ObjectTemplate")
if(applicable) println("Validated $name")
declaration.javadoc.ifPresent {
doc.append("${sanitizeJavadoc(it.toText())} \n")
}

View File

@ -0,0 +1,17 @@
package com.dfsek.terra.api.docs;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* For use in Terra AutoDoc, to specify
* that references to the annotated class
* should be shadowed to the target class.
*/
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface AutoDocShadow {
String value();
}

View File

@ -1,11 +1,11 @@
package com.dfsek.terra.config.loaders.config.sampler.templates.noise;
import com.dfsek.terra.api.docs.AutoDocAlias;
import com.dfsek.terra.api.docs.AutoDocShadow;
import com.dfsek.terra.api.math.noise.samplers.noise.NoiseFunction;
import java.util.function.Function;
@AutoDocAlias("NoiseFunction")
@AutoDocShadow("NoiseFunction")
public class SimpleNoiseTemplate extends NoiseTemplate<NoiseFunction> {
private final Function<Integer, NoiseFunction> samplerSupplier;