boolean anyVars = false;
for (final String optionKey : optionKeys) {
anyVars = true;
final String help = optionDetails.get(optionKey);
variableListElement
.appendChild(new XmlElementBuilder(
"varlistentry", document)
.addChild(
new XmlElementBuilder(
"term", document)
.setText(optionKey)
.build())
.addChild(
new XmlElementBuilder(
"listitem",
document)
.addChild(
new XmlElementBuilder(
"para",
document)
.setText(
help)
.build())
.build()).build());
}
if (!anyVars) {
variableListElement = new XmlElementBuilder("para",
document)
.setText(
"This command does not accept any options.")
.build();
}
// Now we've figured out the options, store this
// individual command
final CDATASection progList = document
.createCDATASection(cmdSyntax.toString());
final String safeName = cmd.value()[0]
.replace("\\", "BCK").replace("/", "FWD")
.replace("*", "ASX");
final Element element = new XmlElementBuilder(
"section", document)
.addAttribute(
"xml:id",
"command-index-"
+ safeName.toLowerCase()
.replace(' ', '-'))
.addChild(
new XmlElementBuilder("title", document)
.setText(cmd.value()[0])
.build())
.addChild(
new XmlElementBuilder("para", document)
.setText(cmd.help()).build())
.addChild(
new XmlElementBuilder("programlisting",
document).addChild(progList)
.build())
.addChild(variableListElement).build();
individualCommands.put(cmdSyntax.toString(), element);
}
}
final Element topSection = document.createElement("section");
topSection.setAttribute("xml:id", "command-index-"
+ section.toLowerCase().replace(' ', '-'));
topSection.appendChild(new XmlElementBuilder("title", document)
.setText(section).build());
topSection.appendChild(new XmlElementBuilder("para", document)
.setText(
section + " are contained in "
+ target.getClass().getName() + ".")
.build());
for (final Element value : individualCommands.values()) {
topSection.appendChild(value);
}
builtSections.add(topSection);
}
final Element appendix = document.createElement("appendix");
appendix.setAttribute("xmlns", "http://docbook.org/ns/docbook");
appendix.setAttribute("version", "5.0");
appendix.setAttribute("xml:id", "command-index");
appendix.appendChild(new XmlElementBuilder("title", document)
.setText("Command Index").build());
appendix.appendChild(new XmlElementBuilder("para", document)
.setText(
"This appendix was automatically built from Roo "
+ AbstractShell.versionInfo() + ".")
.build());
appendix.appendChild(new XmlElementBuilder("para", document)
.setText(
"Commands are listed in alphabetic order, and are shown in monospaced font with any mandatory options you must specify when using the command. Most commands accept a large number of options, and all of the possible options for each command are presented in this appendix.")
.build());
for (final Element section : builtSections) {