00001 /* 00002 * Asterisk -- An open source telephony toolkit. 00003 * 00004 * Copyright (C) 2008, Eliel C. Sardanons (LU1ALY) <eliels@gmail.com> 00005 * 00006 * See http://www.asterisk.org for more information about 00007 * the Asterisk project. Please do not directly contact 00008 * any of the maintainers of this project for assistance; 00009 * the project provides a web site, mailing lists and IRC 00010 * channels for your use. 00011 * 00012 * This program is free software, distributed under the terms of 00013 * the GNU General Public License Version 2. See the LICENSE file 00014 * at the top of the source tree. 00015 */ 00016 00017 #ifndef _ASTERISK_XMLDOC_H 00018 #define _ASTERISK_XMLDOC_H 00019 00020 /*! \file 00021 * \brief Asterisk XML Documentation API 00022 */ 00023 00024 #include "asterisk/xml.h" 00025 #include "asterisk/stringfields.h" 00026 #include "asterisk/strings.h" 00027 00028 /*! \brief From where the documentation come from, this structure is useful for 00029 * use it inside application/functions/manager actions structure. */ 00030 enum ast_doc_src { 00031 AST_XML_DOC, /*!< From XML documentation */ 00032 AST_STATIC_DOC /*!< From application/function registration */ 00033 }; 00034 00035 #ifdef AST_XML_DOCS 00036 00037 struct ao2_container; 00038 00039 /*! \brief Struct that contains the XML documentation for a particular item. Note 00040 * that this is an ao2 ref counted object. 00041 * 00042 * \note 00043 * Each of the ast_str objects are built from the corresponding ast_xmldoc_build_* 00044 * calls 00045 * 00046 * \since 11 00047 */ 00048 struct ast_xml_doc_item { 00049 /*! The syntax of the item */ 00050 struct ast_str *syntax; 00051 /*! Seealso tagged information, if it exists */ 00052 struct ast_str *seealso; 00053 /*! The arguments to the item */ 00054 struct ast_str *arguments; 00055 /*! A synopsis of the item */ 00056 struct ast_str *synopsis; 00057 /*! A description of the item */ 00058 struct ast_str *description; 00059 AST_DECLARE_STRING_FIELDS( 00060 /*! The name of the item */ 00061 AST_STRING_FIELD(name); 00062 /*! The type of the item */ 00063 AST_STRING_FIELD(type); 00064 ); 00065 /*! The next XML documentation item that matches the same name/item type */ 00066 struct ast_xml_doc_item *next; 00067 }; 00068 00069 /*! 00070 * \brief Get the syntax for a specified application or function. 00071 * \param type Application, Function or AGI ? 00072 * \param name Name of the application or function. 00073 * \param module The module the item is in (optional, can be NULL) 00074 * \retval NULL on error. 00075 * \retval The generated syntax in a ast_malloc'ed string. 00076 */ 00077 char *ast_xmldoc_build_syntax(const char *type, const char *name, const char *module); 00078 00079 /*! 00080 * \brief Parse the <see-also> node content. 00081 * \param type 'application', 'function' or 'agi'. 00082 * \param name Application or functions name. 00083 * \param module The module the item is in (optional, can be NULL) 00084 * \retval NULL on error. 00085 * \retval Content of the see-also node. 00086 */ 00087 char *ast_xmldoc_build_seealso(const char *type, const char *name, const char *module); 00088 00089 /*! 00090 * \brief Generate the [arguments] tag based on type of node ('application', 00091 * 'function' or 'agi') and name. 00092 * \param type 'application', 'function' or 'agi' ? 00093 * \param name Name of the application or function to build the 'arguments' tag. 00094 * \param module The module the item is in (optional, can be NULL) 00095 * \retval NULL on error. 00096 * \retval Output buffer with the [arguments] tag content. 00097 */ 00098 char *ast_xmldoc_build_arguments(const char *type, const char *name, const char *module); 00099 00100 /*! 00101 * \brief Colorize and put delimiters (instead of tags) to the xmldoc output. 00102 * \param bwinput Not colorized input with tags. 00103 * \param withcolors Result output with colors. 00104 * \retval NULL on error. 00105 * \retval New malloced buffer colorized and with delimiters. 00106 */ 00107 char *ast_xmldoc_printable(const char *bwinput, int withcolors); 00108 00109 /*! 00110 * \brief Generate synopsis documentation from XML. 00111 * \param type The source of documentation (application, function, etc). 00112 * \param name The name of the application, function, etc. 00113 * \param module The module the item is in (optional, can be NULL) 00114 * \retval NULL on error. 00115 * \retval A malloc'ed string with the synopsis. 00116 */ 00117 char *ast_xmldoc_build_synopsis(const char *type, const char *name, const char *module); 00118 00119 /*! 00120 * \brief Generate description documentation from XML. 00121 * \param type The source of documentation (application, function, etc). 00122 * \param name The name of the application, function, etc. 00123 * \param module The module the item is in (optional, can be NULL) 00124 * \retval NULL on error. 00125 * \retval A malloc'ed string with the formatted description. 00126 */ 00127 char *ast_xmldoc_build_description(const char *type, const char *name, const char *module); 00128 00129 /*! 00130 * \brief Build the documentation for a particular source type 00131 * \param type The source of the documentation items (application, function, etc.) 00132 * 00133 * \retval NULL on error 00134 * \retval An ao2_container populated with ast_xml_doc instances for each item 00135 * that exists for the specified source type 00136 * 00137 * \since 11 00138 */ 00139 struct ao2_container *ast_xmldoc_build_documentation(const char *type); 00140 00141 #endif /* AST_XML_DOCS */ 00142 00143 #endif /* _ASTERISK_XMLDOC_H */