mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 14:35:29 +00:00
@@ -17,7 +17,9 @@ using namespace isc::data;
|
|||||||
class DocGen {
|
class DocGen {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
const string OUTPUT = "../../doc/guide/api.xml";
|
const string OUTPUT = "guide/api.xml";
|
||||||
|
|
||||||
|
bool verbose = false;
|
||||||
|
|
||||||
void loadFiles(const vector<string>& files) {
|
void loadFiles(const vector<string>& files) {
|
||||||
|
|
||||||
@@ -101,9 +103,9 @@ public:
|
|||||||
requireList (x, "support", fname);
|
requireList (x, "support", fname);
|
||||||
requireString(x, "avail", fname);
|
requireString(x, "avail", fname);
|
||||||
requireString(x, "brief", fname);
|
requireString(x, "brief", fname);
|
||||||
requireString(x, "cmd-syntax", fname);
|
|
||||||
|
|
||||||
// They're optional.
|
// They're optional.
|
||||||
|
//requireString(x, "cmd-syntax", fname);
|
||||||
//requireString(x, "cmd-comment", fname);
|
//requireString(x, "cmd-comment", fname);
|
||||||
//requireString(x, "resp-syntax", fname);
|
//requireString(x, "resp-syntax", fname);
|
||||||
//requireString(x, "resp-comment", fname);
|
//requireString(x, "resp-comment", fname);
|
||||||
@@ -143,21 +145,30 @@ public:
|
|||||||
|
|
||||||
// Generate a list of components:
|
// Generate a list of components:
|
||||||
set<string> all_daemons;
|
set<string> all_daemons;
|
||||||
|
set<string> all_hooks;
|
||||||
for (auto cmd : cmds_) {
|
for (auto cmd : cmds_) {
|
||||||
auto daemons = cmd.second->get("support");
|
auto daemons = cmd.second->get("support");
|
||||||
|
auto hook = cmd.second->get("hook");
|
||||||
for (int i = 0; i < daemons->size(); i++) {
|
for (int i = 0; i < daemons->size(); i++) {
|
||||||
string daemon = daemons->get(i)->stringValue();
|
string daemon = daemons->get(i)->stringValue();
|
||||||
if (all_daemons.find(daemon) == all_daemons.end()) {
|
if (all_daemons.find(daemon) == all_daemons.end()) {
|
||||||
all_daemons.insert(daemon);
|
all_daemons.insert(daemon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (hook) {
|
||||||
|
string hook_txt = hook->stringValue();
|
||||||
|
if (all_hooks.find(hook_txt) == all_hooks.end()) {
|
||||||
|
all_hooks.insert(hook_txt);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "### " << all_daemons.size() << " daemon(s) detected." << endl;
|
cout << "### " << all_daemons.size() << " daemon(s) detected." << endl;
|
||||||
|
cout << "### " << all_hooks.size() << " hook lib(s) detected." << endl;
|
||||||
|
|
||||||
for (auto daemon : all_daemons) {
|
for (auto daemon : all_daemons) {
|
||||||
f << "<para xml:id=\"commands-" << daemon << "\">"
|
f << "<para xml:id=\"commands-" << daemon << "\">"
|
||||||
<< "Commands supported by " << daemon << ": ";
|
<< "Commands supported by " << daemon << " daemon: ";
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (auto cmd : cmds_) {
|
for (auto cmd : cmds_) {
|
||||||
@@ -179,6 +190,28 @@ public:
|
|||||||
f << ".</para>" << endl;
|
f << ".</para>" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto hook : all_hooks) {
|
||||||
|
f << "<para xml:id=\"commands-" << hook << "-lib\">"
|
||||||
|
<< "Commands supported by " << hook << " hook library: ";
|
||||||
|
|
||||||
|
bool first = true;
|
||||||
|
for (auto cmd : cmds_) {
|
||||||
|
|
||||||
|
first = true;
|
||||||
|
auto daemon_hook = cmd.second->get("hook");
|
||||||
|
if (!daemon_hook || daemon_hook->stringValue() != hook) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!first) {
|
||||||
|
f << ", ";
|
||||||
|
}
|
||||||
|
generateCmdLink(f, cmd.first);
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
f << ".</para>" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateOutput() {
|
void generateOutput() {
|
||||||
@@ -199,11 +232,16 @@ public:
|
|||||||
|
|
||||||
f << "</chapter>" << endl;
|
f << "</chapter>" << endl;
|
||||||
|
|
||||||
cout << "----------------" << endl;
|
|
||||||
ofstream file(OUTPUT.c_str(), ofstream::trunc);
|
ofstream file(OUTPUT.c_str(), ofstream::trunc);
|
||||||
file << f.str();
|
file << f.str();
|
||||||
// cout << f.str();
|
if (verbose) {
|
||||||
cout << "----------------" << endl;
|
cout << "----------------" << endl;
|
||||||
|
cout << f.str();
|
||||||
|
cout << "----------------" << endl;
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
cout << "Output written to " << OUTPUT << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateCommands(stringstream& f){
|
void generateCommands(stringstream& f){
|
||||||
@@ -283,18 +321,31 @@ void generateCommand(stringstream& f, const ElementPtr& cmd) {
|
|||||||
f << "</para>" << endl << endl;
|
f << "</para>" << endl << endl;
|
||||||
|
|
||||||
// availability
|
// availability
|
||||||
f << "<para>Availability: " << cmd->get("avail")->stringValue() << "</para>"
|
f << "<para>Availability: " << cmd->get("avail")->stringValue();
|
||||||
<< endl << endl;
|
auto hook = cmd->get("hook");
|
||||||
|
if (hook) {
|
||||||
|
f << " (<link linkend=\"commands-" << hook->stringValue() << "-lib\">"
|
||||||
|
<< hook->stringValue() << "</link>)";
|
||||||
|
} else {
|
||||||
|
f << " (built-in)";
|
||||||
|
}
|
||||||
|
|
||||||
|
f << "</para>" << endl << endl;
|
||||||
|
|
||||||
// description and examples
|
// description and examples
|
||||||
f << "<para>Description and examples: See <xref linkend=\"command-"
|
f << "<para>Description and examples: See <xref linkend=\"command-"
|
||||||
<< cmd->get("name")->stringValue() << "\"/></para>" << endl << endl;
|
<< cmd->get("name")->stringValue() << "\"/></para>" << endl << endl;
|
||||||
|
|
||||||
// Command syntax:
|
// Command syntax:
|
||||||
f << "<para>Command syntax:" << endl
|
f << "<para>Command syntax:" << endl;
|
||||||
<< " <screen>" << escapeString(cmd->get("cmd-syntax")->stringValue())
|
if (cmd->contains("cmd-syntax")) {
|
||||||
<< "</screen>"
|
f << " <screen>" << escapeString(cmd->get("cmd-syntax")->stringValue())
|
||||||
<< endl;
|
<< "</screen>" << endl;
|
||||||
|
} else {
|
||||||
|
f << " <screen>{" << endl
|
||||||
|
<< " \"command\": \"" << cmd->get("name")->stringValue() << "\"" << endl
|
||||||
|
<< "}</screen>" << endl;
|
||||||
|
}
|
||||||
if (cmd->contains("cmd-comment")) {
|
if (cmd->contains("cmd-comment")) {
|
||||||
f << cmd->get("cmd-comment")->stringValue();
|
f << cmd->get("cmd-comment")->stringValue();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user