Commit 6cc5d94b authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰

[gitlab10/5422] list for specific daemons are now generated.

parent e0021f33
......@@ -3,6 +3,7 @@
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <exceptions/exceptions.h>
#include <cc/data.h>
......@@ -120,30 +121,79 @@ public:
f << "<!-- autogenerated using cmd_docgen. Do not edit by hand! -->" << endl;
}
void generateOutput() {
stringstream f;
generateCopyright(f);
f << "<chapter xmlns=\"http://docbook.org/ns/docbook\" version=\"5.0\" xml:id=\"api\">"
<< endl;
f << " <title>API Reference</title>" << endl;
void generateCmdLink(stringstream& f, const string& cmd) {
f << "<command><link linkend=\"ref-" << cmd << "\">" << cmd << "</link></command>" << endl;
}
// Generate initial list of commands
void generateLists(stringstream& f) {
// Generate a list of all commands
f << " <para>Kea currently supports " << cmds_.size() << " commands:" << endl;
bool first = true;
for (auto cmd : cmds_) {
if (!first) {
f << ", ";
generateCmdLink(f, cmd.first);
}
f << "<command>" << cmd.first << "</command>" << endl;
first = false;
}
f << ".</para>" << endl;
// Generate a list of components:
set<string> 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 << "<para xml:id=\"commands-" << daemon << "\">"
<< "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 << ".</para>" << endl;
}
}
void generateOutput() {
stringstream f;
generateCopyright(f);
f << "<chapter xmlns=\"http://docbook.org/ns/docbook\" version=\"5.0\" xml:id=\"api\">"
<< endl;
f << " <title>API Reference</title>" << 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 << "<para><command>" << cmd->get("name")->stringValue() << "</command> - "
f << "<para xml:id=\"ref-" << cmd->get("name")->stringValue() << "\"><command>"
<< cmd->get("name")->stringValue() << "</command> - "
<< cmd->get("brief")->stringValue() << "</para>" << 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 << "<command><link linkend=\"commands-" << daemons->get(i)->stringValue()
<< "\">" << daemons->get(i)->stringValue() << "</link></command>";
}
f << "</para>" << endl << endl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment