Skip to content

Commit

Permalink
[Doctools] Fix //expand listing, ensure no missed commands
Browse files Browse the repository at this point in the history
  • Loading branch information
octylFractal committed Aug 30, 2019
1 parent 44bffc5 commit 299d703
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -57,6 +57,7 @@ class DocumentationPrinter private constructor() {
.map { it.name to it }.toList().toMap() .map { it.name to it }.toList().toMap()
private val cmdOutput = StringBuilder() private val cmdOutput = StringBuilder()
private val permsOutput = StringBuilder() private val permsOutput = StringBuilder()
private val matchedCommands = mutableSetOf<String>()


private suspend inline fun <reified T> SequenceScope<String>.yieldAllCommandsIn() { private suspend inline fun <reified T> SequenceScope<String>.yieldAllCommandsIn() {
val sourceFile = Paths.get("worldedit-core/src/main/java/" + T::class.qualifiedName!!.replace('.', '/') + ".java") val sourceFile = Paths.get("worldedit-core/src/main/java/" + T::class.qualifiedName!!.replace('.', '/') + ".java")
Expand Down Expand Up @@ -93,7 +94,7 @@ class DocumentationPrinter private constructor() {


dumpSection("Selection Commands") { dumpSection("Selection Commands") {
yieldAllCommandsIn<SelectionCommands>() yieldAllCommandsIn<SelectionCommands>()
yieldAllCommandsIn<ExpandCommands>() yield("/expand")
} }


dumpSection("Region Commands") { dumpSection("Region Commands") {
Expand Down Expand Up @@ -144,6 +145,9 @@ class DocumentationPrinter private constructor() {
} }


writeFooter() writeFooter()

val missingCommands = commands.keys.filterNot { it in matchedCommands }
require(missingCommands.isEmpty()) { "Missing commands: $missingCommands" }
} }


private fun writeHeader() { private fun writeHeader() {
Expand Down Expand Up @@ -214,6 +218,7 @@ Other Permissions


val prefix = TextConfig.getCommandPrefix() val prefix = TextConfig.getCommandPrefix()
val commands = sequence(addCommandNames).map { this.commands.getValue(it) }.toList() val commands = sequence(addCommandNames).map { this.commands.getValue(it) }.toList()
matchedCommands.addAll(commands.map { it.name })


cmdsToPerms(commands, prefix) cmdsToPerms(commands, prefix)


Expand Down

0 comments on commit 299d703

Please sign in to comment.