diff --git a/tools/cmd-docgen/kea_docgen.cc b/tools/cmd-docgen/kea_docgen.cc index 2b0758dc61bced37a97c3f11cebc7231f4b5a992..b47b53652f2ef0f65380110e679e0e35438cfa8c 100644 --- a/tools/cmd-docgen/kea_docgen.cc +++ b/tools/cmd-docgen/kea_docgen.cc @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -120,30 +121,79 @@ public: f << "" << endl; } - void generateOutput() { - - stringstream f; - - generateCopyright(f); - - f << "" - << endl; - f << " API Reference" << endl; + void generateCmdLink(stringstream& f, const string& cmd) { + f << "" << cmd << "" << endl; + } - // Generate initial list of commands + void generateLists(stringstream& f) { + // Generate a list of all commands f << " Kea currently supports " << cmds_.size() << " commands:" << endl; bool first = true; for (auto cmd : cmds_) { if (!first) { f << ", "; + generateCmdLink(f, cmd.first); } - f << "" << cmd.first << "" << endl; + first = false; } f << "." << endl; + // Generate a list of components: + set all_daemons; + for (auto cmd : cmds_) { + auto daemons = cmd.second->get("support"); + for (int i = 0; i < daemons->size(); i++) { + string daemon = daemons->get(i)->stringValue(); + if (all_daemons.find(daemon) == all_daemons.end()) { + all_daemons.insert(daemon); + } + } + } + + cout << "### " << all_daemons.size() << " daemon(s) detected." << endl; + + for (auto daemon : all_daemons) { + f << "" + << "Commands supported by " << daemon << ": "; + + bool first = true; + for (auto cmd : cmds_) { + + first = true; + auto daemons = cmd.second->get("support"); + for (auto d : daemons->listValue()) { + if (d->stringValue() == daemon) { + if (!first) { + f << ", "; + } + generateCmdLink(f, cmd.first); + first = false; + break; // get to next command + } + } + } + + f << "." << endl; + } + + } + + void generateOutput() { + + stringstream f; + + generateCopyright(f); + + f << "" + << endl; + f << " API Reference" << endl; + + + generateLists(f); + // Generate actual commands references. generateCommands(f); @@ -215,7 +265,8 @@ string standardResponseComment() { void generateCommand(stringstream& f, const ElementPtr& cmd) { // command overview - f << "" << cmd->get("name")->stringValue() << " - " + f << "get("name")->stringValue() << "\">" + << cmd->get("name")->stringValue() << " - " << cmd->get("brief")->stringValue() << "" << endl << endl; // command can be issued to the following daemons @@ -226,7 +277,8 @@ void generateCommand(stringstream& f, const ElementPtr& cmd) { f << ", "; } - f << daemons->get(i)->stringValue(); + f << "get(i)->stringValue() + << "\">" << daemons->get(i)->stringValue() << ""; } f << "" << endl << endl;