mirror of https://github.com/hykilpikonna/AquaDX
[O] Do not overwrite println in gendocs
parent
73efa4fe91
commit
d5296763ad
|
@ -30,32 +30,34 @@ fun main() {
|
||||||
|
|
||||||
var buf = ""
|
var buf = ""
|
||||||
|
|
||||||
fun println(s: String) {
|
fun write(s: String) {
|
||||||
buf += s + "\n"
|
buf += s + "\n"
|
||||||
kotlin.io.println(s)
|
println(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println(classes)
|
||||||
|
|
||||||
// Loop through all classes
|
// Loop through all classes
|
||||||
classes.filter { it.isAnnotationPresent(apiCls) }.forEach { cls ->
|
classes.filter { it.isAnnotationPresent(apiCls) }.forEach { cls ->
|
||||||
val base = cls.getAnnotation(API::class.java).value.joinToString(", ")
|
val base = cls.getAnnotation(API::class.java).value.joinToString(", ")
|
||||||
println("\n\n### ${cls.simpleName} : $base\n")
|
write("\n\n### ${cls.simpleName} : $base\n")
|
||||||
println("Located at: [${cls.name}](${cls.name.replace('.', '/')}.kt)")
|
write("Located at: [${cls.name}](${cls.name.replace('.', '/')}.kt)")
|
||||||
|
|
||||||
// Loop through all functions
|
// Loop through all functions
|
||||||
cls.kotlin.declaredFunctions.filter { it.hasAnnotation<API>() }.forEach { fn ->
|
cls.kotlin.declaredFunctions.filter { it.hasAnnotation<API>() }.forEach { fn ->
|
||||||
val endpoint = fn.findAnnotation<API>()!!.value.joinToString(", ")
|
val endpoint = fn.findAnnotation<API>()!!.value.joinToString(", ")
|
||||||
val doc = fn.findAnnotation<Doc>()
|
val doc = fn.findAnnotation<Doc>()
|
||||||
|
|
||||||
println("\n**${base.replace("/api/v2", "")}$endpoint** : ${doc?.desc ?: "No description"}\n")
|
write("\n**${base.replace("/api/v2", "")}$endpoint** : ${doc?.desc ?: "No description"}\n")
|
||||||
|
|
||||||
// Parameters
|
// Parameters
|
||||||
fn.parameters.filter { it.hasAnnotation<RP>() }.forEach { param ->
|
fn.parameters.filter { it.hasAnnotation<RP>() }.forEach { param ->
|
||||||
val paramName = param.name
|
val paramName = param.name
|
||||||
val paramType = param.type.javaType.typeName.split('.').last()
|
val paramType = param.type.javaType.typeName.split('.').last()
|
||||||
println("* $paramName: $paramType")
|
write("* $paramName: $paramType")
|
||||||
}
|
}
|
||||||
|
|
||||||
doc?.ret?.let { println("* **Returns**: $it") }
|
doc?.ret?.let { write("* **Returns**: $it") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue