]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5422] template generator added
authorTomek Mrugalski <tomasz@isc.org>
Tue, 12 Jun 2018 22:53:43 +0000 (00:53 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Tue, 29 Oct 2019 17:57:13 +0000 (18:57 +0100)
tools/cmd-docgen/.gitignore [new file with mode: 0644]
tools/cmd-docgen/cmd_docgen.cc
tools/cmd-docgen/generate-templates [new file with mode: 0755]

diff --git a/tools/cmd-docgen/.gitignore b/tools/cmd-docgen/.gitignore
new file mode 100644 (file)
index 0000000..a6c57f5
--- /dev/null
@@ -0,0 +1 @@
+*.json
index 7febabeed91a5f50c25a821a95d32cf2036d36d7..027a145bd9805ed86de0e7dded054b6e774359a7 100644 (file)
@@ -131,15 +131,18 @@ public:
         f << "  <title>API Reference</title>" << endl;
 
         // Generate initial list of commands
-        f << "  <para>Kea currently supports " << cmds_.size() << " commands:" << endl
-          << "    <orderedlist>" << endl;
+        f << "  <para>Kea currently supports " << cmds_.size() << " commands:" << endl;
 
+        bool first = true;
         for (auto cmd : cmds_) {
-            f << "      <listitem><simpara>" << cmd.first << "</simpara></listitem>" << endl;
+            if (!first) {
+                f << ", ";
+            }
+            f << "<command>" << cmd.first << "</command>" << endl;
+            first = false;
         }
 
-        f << "    </orderedlist>" << endl;
-        f << "  </para>" << endl;
+        f << ".</para>" << endl;
 
         // Generate actual commands references.
         generateCommands(f);
diff --git a/tools/cmd-docgen/generate-templates b/tools/cmd-docgen/generate-templates
new file mode 100755 (executable)
index 0000000..7f5353f
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/bash
+while read -r LINE; do
+    F=$LINE.json
+    echo "{" > $F
+    echo "    \"name\": \"$LINE\",\n" >> $F
+    echo "    \"brief\": \"a sentence or two explaining what this command does\",\n" >> $F
+    echo "    \"support\": [ \"kea-dhcp4\", \"kea-dhcp6\" ],\n" >> $F
+    echo "    \"avail\": \"first version, possible a hook library name and (premium) if applicable\",\n" >> $F
+
+    echo "    \"cmd-syntax\": \"Syntax of the command\",\n" >> $F
+    echo "    \"cmd-comment\": \"Possibly some extra comments after the syntax.\",\n" >> $F
+
+    echo "    \"resp-syntax\": \"Syntax of the response\",\n" >> $F
+    echo "    \"resp-comment\": \"Optional extra comments after the respone syntax.\"\n" >> $F
+    echo "}" >> $F
+
+    echo "$LINE generated."
+done < cmds-list