From e0dfe4832be53987ea5beb5c39e9985d5bc1aa15 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sun, 8 Feb 2015 00:42:21 +0000
Subject: Added code to generate HTML command reference for website
---
src/command/command.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
(limited to 'src/command/command.c')
diff --git a/src/command/command.c b/src/command/command.c
index 9698f0bd..1a673568 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -36,6 +36,7 @@
#include
#include
#include
+#include
#include
#include
@@ -2990,3 +2991,55 @@ _account_autocomplete(const char * const input)
found = autocomplete_param_with_ac(input, "/account", account_ac, TRUE);
return found;
}
+
+static int
+_cmp_command(Command *cmd1, Command *cmd2)
+{
+ return g_strcmp0(cmd1->cmd, cmd2->cmd);
+}
+
+void
+command_docgen(void)
+{
+ GList *cmds = NULL;
+ unsigned int i;
+ for (i = 0; i < ARRAY_SIZE(command_defs); i++) {
+ Command *pcmd = command_defs+i;
+ cmds = g_list_insert_sorted(cmds, pcmd, (GCompareFunc)_cmp_command);
+ }
+
+ FILE *toc_fragment = fopen("toc_fragment.html", "w");
+ FILE *main_fragment = fopen("main_fragment.html", "w");
+
+ fputs("- \n", toc_fragment);
+ fputs("
\n", main_fragment);
+
+ GList *curr = cmds;
+ while (curr) {
+ Command *pcmd = curr->data;
+
+ fprintf(toc_fragment, "%s,\n", &pcmd->cmd[1], pcmd->cmd);
+
+ fprintf(main_fragment, "\n", &pcmd->cmd[1]);
+ fprintf(main_fragment, "%s
\n", pcmd->cmd);
+ fputs("Usage:
\n", main_fragment);
+ fprintf(main_fragment, "%s
\n", pcmd->help.usage);
+
+ fputs("Details:
\n", main_fragment);
+ fputs("", main_fragment);
+ int i = 2;
+ while (pcmd->help.long_help[i] != NULL) {
+ fprintf(main_fragment, "%s\n", pcmd->help.long_help[i++]);
+ }
+ fputs("
\nback to top
\n", main_fragment);
+ fputs("\n", main_fragment);
+
+ curr = g_list_next(curr);
+ }
+
+ fputs("\n", toc_fragment);
+
+ fclose(toc_fragment);
+ fclose(main_fragment);
+ g_list_free(cmds);
+}
\ No newline at end of file
--
cgit 1.4.1-2-gfad0