summaryrefslogtreecommitdiff
path: root/main/pbx.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/pbx.c')
-rw-r--r--main/pbx.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/main/pbx.c b/main/pbx.c
index 042fb8b14..3e0070aa4 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -3056,6 +3056,56 @@ static int handle_show_application(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+#ifdef AST_DEVMODE
+static char core_dumpappdocs_help[] =
+"Usage: core dumpappdocs [application]\n"
+" Dump Application documentation to \\tmp\\ast_appdocs.tex.\n";
+
+static int handle_core_dumpappdocs(int fd, int argc, char *argv[])
+{
+ struct ast_app *app;
+ FILE *f;
+ char *appname = NULL;
+ const char *fn = "/tmp/ast_appdocs.tex";
+
+ if (argc > 3)
+ appname = argv[3];
+
+ if (!(f = fopen(fn, "w+"))) {
+ ast_cli(fd, "Unable to open %s for writing!\n", fn);
+ return RESULT_FAILURE;
+ }
+
+ fprintf(f, "%% This file is automatically generated. Any manual edits will be lost.\n");
+
+ AST_LIST_LOCK(&apps);
+ AST_LIST_TRAVERSE(&apps, app, list) {
+ if (appname && strcasecmp(app->name, appname))
+ continue;
+
+ fprintf(f, "\\section{%s}\n"
+ "\\subsection{Synopsis}\n"
+ "\\begin{verbatim}\n"
+ "%s\n"
+ "\\end{verbatim}\n"
+ "\\subsection{Description}\n"
+ "\\begin{verbatim}\n"
+ "%s\n"
+ "\\end{verbatim}\n\n\n", app->name, app->synopsis, app->description);
+
+ if (appname)
+ break;
+ }
+ AST_LIST_UNLOCK(&apps);
+
+ fclose(f);
+
+ ast_cli(fd, "Documentation has been dumped to %s\n", fn);
+
+ return RESULT_SUCCESS;
+}
+#endif
+
/*! \brief handle_show_hints: CLI support for listing registered dial plan hints */
static int handle_show_hints(int fd, int argc, char *argv[])
{
@@ -3730,6 +3780,12 @@ static struct ast_cli_entry pbx_cli[] = {
handle_show_application, "Describe a specific dialplan application",
show_application_help, complete_show_application },
+#ifdef AST_DEVMODE
+ { { "core", "dumpappdocs", NULL },
+ handle_core_dumpappdocs, "Dump App docs in LaTeX format",
+ core_dumpappdocs_help, NULL },
+#endif
+
{ { "core", "set", "global", NULL },
handle_set_global, "Set global dialplan variable",
set_global_help },