[svn-commits] bkruse: branch group/appdocsxml r128339 - in /team/group/appdocsxml: ./ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat Jul 5 19:20:14 CDT 2008


Author: bkruse
Date: Sat Jul  5 19:20:14 2008
New Revision: 128339

URL: http://svn.digium.com/view/asterisk?view=rev&rev=128339
Log:
Sample documentation for Application

Check for NULL passed in register function, try
to find the values in the XML blob

Modified:
    team/group/appdocsxml/Makefile
    team/group/appdocsxml/main/pbx.c

Modified: team/group/appdocsxml/Makefile
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/Makefile?view=diff&rev=128339&r1=128338&r2=128339
==============================================================================
--- team/group/appdocsxml/Makefile (original)
+++ team/group/appdocsxml/Makefile Sat Jul  5 19:20:14 2008
@@ -487,7 +487,7 @@
 	@echo "<?xml version="1.0" encoding="UTF-8"?>" > documentation.xml
 	@echo "<docs>" >> documentation.xml
 	@for x in $(MOD_SUBDIRS); do \
-		echo -n " $$x " ; \
+		echo -n "$$x " ; \
 		for i in $$x/*.c; do \
 			$(AWK) -f build_tools/get_documentation $$i >> documentation.xml ; \
 		done ; \

Modified: team/group/appdocsxml/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/main/pbx.c?view=diff&rev=128339&r1=128338&r2=128339
==============================================================================
--- team/group/appdocsxml/main/pbx.c (original)
+++ team/group/appdocsxml/main/pbx.c Sat Jul  5 19:20:14 2008
@@ -437,6 +437,24 @@
 static int totalcalls;
 
 static AST_RWLIST_HEAD_STATIC(acf_root, ast_custom_function);
+
+/*** DOCUMENTATION
+	<application name="Answer" language="en">
+		<synopsis>
+			Answer a channel if ringing.
+		</synopsis>
+		<description>
+			  Answer([delay]): If the call has not been answered, this application will
+			answer it. Otherwise, it has no effect on the call. If a delay is specified,
+			Asterisk will wait this number of milliseconds before returning to
+			the dialplan after answering the call.
+		</description>
+		<option name="delay" required="false">
+			Delay that Asterisk will wait in milliseconds before returning to the dialplan after answering the call.
+		</option>
+	</application>
+
+ ***/
 
 /*! \brief Declaration of builtin applications */
 static struct pbx_builtin {
@@ -2601,6 +2619,41 @@
 
 	acf->mod = mod;
 
+	/* Let's try to find it in the Documentation XML */
+	if (!acf->desc || !acf->synopsis) {
+		mxml_node_t *node, *lang_node, *desc, *syn;
+		node = lang_node = desc = syn = NULL;
+		if (!documentation_tree) {
+			ast_log(LOG_WARNING, "Cannot get description or synopsis for Dialplan Function, Not Registering It.\n");
+			return -1;
+		}
+		node = mxmlFindElement(documentation_tree, documentation_tree, "function", "name", acf->name, MXML_DESCEND);
+
+		if (!node) {
+			ast_log(LOG_WARNING, "Cannot find Function Documentation for Func: '%s'\n", acf->name);
+			return -1;
+		}
+
+	
+		lang_node = mxmlFindElement(node, documentation_tree, "application", "language", documentation_language, MXML_DESCEND);	
+	
+		/* Could not find language, use the default one without a language */
+		if (!lang_node) {
+			lang_node = node;
+		}
+	
+		syn = mxmlFindElement(lang_node, documentation_tree, "synopsis", NULL, NULL, MXML_DESCEND);
+		desc = mxmlFindElement(lang_node, documentation_tree, "description", NULL, NULL, MXML_DESCEND);
+	    
+		if (!syn || !desc || !syn->child || !desc->child) {
+			ast_log(LOG_WARNING, "Cannot find Application description or synopsis for app: '%s'\n", app);
+			return -1;
+		}
+
+		acf->synopsis =  syn->child->value.opaque;
+		acf->desc = desc->child->value.opaque;
+	}
+
 	AST_RWLIST_WRLOCK(&acf_root);
 
 	AST_RWLIST_TRAVERSE(&acf_root, cur, acflist) {




More information about the svn-commits mailing list