mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 08:25:31 +00:00
cleanup
This commit is contained in:
parent
0e3b40564b
commit
4247f85f70
@ -19,11 +19,11 @@ abstract class GenerateDocsTask : DefaultTask() {
|
|||||||
fun generateDocs() {
|
fun generateDocs() {
|
||||||
project.extensions.getByType(JavaPluginExtension::class.java).sourceSets.forEach { sources ->
|
project.extensions.getByType(JavaPluginExtension::class.java).sourceSets.forEach { sources ->
|
||||||
val classes = HashMap<String, ClassNode>()
|
val classes = HashMap<String, ClassNode>()
|
||||||
sources.java.classesDirectory.get().asFileTree.forEach {
|
sources.java.classesDirectory.get().asFileTree.forEach { file ->
|
||||||
if (it.name.endsWith(".class")) {
|
if (file.name.endsWith(".class")) {
|
||||||
val node = createClassNode(FileInputStream(it))
|
val node = createClassNode(FileInputStream(file))
|
||||||
if (node.fields.stream().anyMatch {
|
if (node.fields.stream().anyMatch { field ->
|
||||||
it.visibleAnnotations?.stream()?.anyMatch {
|
field.visibleAnnotations?.stream()?.anyMatch {
|
||||||
it.desc.equals(descriptor(Value::class.java.canonicalName))
|
it.desc.equals(descriptor(Value::class.java.canonicalName))
|
||||||
} == true
|
} == true
|
||||||
}) {
|
}) {
|
||||||
@ -33,7 +33,7 @@ abstract class GenerateDocsTask : DefaultTask() {
|
|||||||
.get()
|
.get()
|
||||||
.asFile
|
.asFile
|
||||||
.toPath()
|
.toPath()
|
||||||
.relativize(it.toPath())
|
.relativize(file.toPath())
|
||||||
.toString()
|
.toString()
|
||||||
.substringBeforeLast('.')] = node
|
.substringBeforeLast('.')] = node
|
||||||
}
|
}
|
||||||
@ -43,16 +43,16 @@ abstract class GenerateDocsTask : DefaultTask() {
|
|||||||
val docsDir = File(project.buildDir, "tectonic")
|
val docsDir = File(project.buildDir, "tectonic")
|
||||||
docsDir.mkdirs()
|
docsDir.mkdirs()
|
||||||
|
|
||||||
classes.forEach { name, clazz ->
|
classes.forEach { (name, clazz) ->
|
||||||
val template = DocumentedTemplate(name.substringAfterLast('/'))
|
val template = DocumentedTemplate(name.substringAfterLast('/'))
|
||||||
clazz.fields
|
clazz.fields
|
||||||
.stream()
|
.stream()
|
||||||
.filter {
|
.filter { field ->
|
||||||
it.visibleAnnotations?.stream()?.anyMatch {
|
field.visibleAnnotations?.stream()?.anyMatch {
|
||||||
it.desc.equals(descriptor(Value::class.java.canonicalName))
|
it.desc.equals(descriptor(Value::class.java.canonicalName))
|
||||||
} == true
|
} == true
|
||||||
}.forEach {
|
}.forEach { field ->
|
||||||
val annotations = it.visibleAnnotations
|
val annotations = field.visibleAnnotations
|
||||||
|
|
||||||
val description = StringBuilder()
|
val description = StringBuilder()
|
||||||
|
|
||||||
@ -62,23 +62,23 @@ abstract class GenerateDocsTask : DefaultTask() {
|
|||||||
description.append(it.values[1])
|
description.append(it.values[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
val name = StringBuilder()
|
val keyName = StringBuilder()
|
||||||
|
|
||||||
if (annotations.stream().anyMatch { it.desc.equals(descriptor(Final::class.java.canonicalName)) }) {
|
if (annotations.stream().anyMatch { it.desc.equals(descriptor(Final::class.java.canonicalName)) }) {
|
||||||
name.append("final ")
|
keyName.append("final ")
|
||||||
}
|
}
|
||||||
|
|
||||||
name.append(descriptorToHumanReadable(it.desc))
|
keyName.append(descriptorToHumanReadable(field.desc))
|
||||||
.append(" ")
|
.append(" ")
|
||||||
|
|
||||||
annotations.stream().filter {
|
annotations.stream().filter {
|
||||||
it.desc.equals(descriptor(Value::class.java.canonicalName))
|
it.desc.equals(descriptor(Value::class.java.canonicalName))
|
||||||
}.forEach {
|
}.forEach {
|
||||||
name.append(it.values[1])
|
keyName.append(it.values[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
template.add(name.toString(), description.toString().ifBlank {
|
template.add(keyName.toString(), description.toString().ifBlank {
|
||||||
println("No description provided for field " + it.name)
|
println("No description provided for field " + field.name)
|
||||||
"*No description provided.*"
|
"*No description provided.*"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user