/*#define DEBUG 1*/
/*
* "$Id: mxmldoc.c 451 2014-01-04 21:50:06Z msweet $"
*
* Documentation generator using Mini-XML, a small XML-like file parsing
* library.
*
* Copyright 2003-2014 by Michael R Sweet.
*
* These coded instructions, statements, and computer programs are the
* property of Michael R Sweet and are protected by Federal copyright
* law. Distribution and use rights are outlined in the file "COPYING"
* which should have been included with this file. If this file is
* missing or damaged, see the license at:
*
* http://www.minixml.org/
*/
/*
* Include necessary headers...
*/
#include "config.h"
#include "mxml.h"
#include <time.h>
#include <sys/stat.h>
#ifndef WIN32
# include <dirent.h>
# include <unistd.h>
#endif /* !WIN32 */
#ifdef __APPLE__
# include <spawn.h>
# include <sys/wait.h>
extern char **environ;
#endif /* __APPLE__ */
/*
* This program scans source and header files and produces public API
* documentation for code that conforms to the CUPS Configuration
* Management Plan (CMP) coding standards. Please see the following web
* page for details:
*
* http://www.cups.org/cmp.html
*
* Using Mini-XML, this program creates and maintains an XML representation
* of the public API code documentation which can then be converted to HTML
* as desired. The following is a poor-man's schema:
*
* <?xml version="1.0"?>
* <mxmldoc xmlns="http://www.easysw.com"
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
* xsi:schemaLocation="http://www.minixml.org/mxmldoc.xsd">
*
* <namespace name=""> [optional...]
* <constant name="">
* <description>descriptive text</description>
* </constant>
*
* <enumeration name="">
* <description>descriptive text</description>
* <constant name="">...</constant>
* </enumeration>
*
* <typedef name="">
* <description>descriptive text</description>
* <type>type string</type>
* </typedef>
*
* <function name="" scope="">
* <description>descriptive text</description>
* <argument name="" direction="I|O|IO" default="">
* <description>descriptive text</description>
* <type>type string</type>
* </argument>
* <returnvalue>
* <description>descriptive text</description>
* <type>type string</type>
* </returnvalue>
* <seealso>function names separated by spaces</seealso>
* </function>
*
* <variable name="" scope="">
* <description>descriptive text</description>
* <type>type string</type>
* </variable>
*
* <struct name="">
* <description>descriptive text</description>
* <variable name="">...</variable>
* <function name="">...</function>
* </struct>
*
* <union name="">
* <description>descriptive text</description>
* <variable name="">...</variable>
* </union>
*
* <class name="" parent="">
* <description>descriptive text</description>
* <class name="">...</class>
* <enumeration name="">...</enumeration>
* <function name="">...</function>
* <struct name="">...</struct>
* <variable name="">...</variable>
* </class>
* </namespace>
* </mxmldoc>
*/
/*
* Basic states for file parser...
*/
#define STATE_NONE 0 /* No state - whitespace, etc. */
#define STATE_PREPROCESSOR 1 /* Preprocessor directive */
#define STATE_C_COMMENT 2 /* Inside a C comment */
#define STATE_CXX_COMMENT 3 /* Inside a C++ comment */
#define STATE_STRING 4 /* Inside a string constant */
#define STATE_CHARACTER 5 /* Inside a character constant */
#define STATE_IDENTIFIER 6 /* Inside a keyword/identifier */
/*
* Output modes...
*/
#define OUTPUT_NONE 0 /* No output */
#define OUTPUT_HTML 1 /* Output HTML */
#define OUTPUT_XML 2 /* Output XML */
#define OUTPUT_MAN 3 /* Output nroff/man */
#define OUTPUT_TOKENS 4 /* Output docset Tokens.xml file */
/*
* Local functions...
*/
static mxml_node_t *add_variable(mxml_node_t *parent, const char *name,
mxml_node_t *type);
static mxml_node_t *find_public(mxml_node_t *node, mxml_node_t *top,
const char *name);
static char *get_comment_info(mxml_node_t *description);
static char *get_text(mxml_node_t *node, char *buffer, int buflen);
static mxml_type_t load_cb(mxml_node_t *node);
static mxml_node_t *new_documentation(mxml_node_t **mxmldoc);
static int remove_directory(const char *path);
static void safe_strcpy(char *dst, const char *src);
static int scan_file(const char *filename, FILE *fp,
mxml_node_t *doc);
static void sort_node(mxml_node_t *tree, mxml_node_t *func);
static void update_comment(mxml_node_t *parent,
mxml_node_t *comment);
static void usage(const char *option);
static void write_description(FILE *out, mxml_node_t *description,
const char *element, int summary);
static void write_element(FILE *out, mxml_node_t *doc,
mxml_node_t *element, int mode);
static void write_file(FILE *out, const char *file);
static void write_function(FILE *out, mxml_node_t *doc,
mxml_node_t *function, int level);
static void write_html(const char *section, const char *title,
const char *footerfile,
const char *headerfile,
const char *introfile, const char *cssfile,
const char *framefile,
const char *docset, const char *docversion,
const char *feedname, const char *feedurl,
mxml_node_t *doc);
static void write_html_head(FILE *out, const char *section,
const char *title, const char *cssfile);
static void write_man(const char *man_name, const char *section,
const char *title, const char *headerfile,
const char *footerfile, const char *introfile,
mxml_node_t *doc);
static void write_scu(FILE *out, mxml_node_t *doc,
mxml_node_t *scut);
static void write_string(FILE *out, const char *s, int mode);
static void write_toc(FILE *out, mxml_node_t *doc,
const char *introfile, const char *target,
int xml);
static void write_tokens(FILE *out, mxml_node_t *doc,
const char *path);
static const char *ws_cb(mxml_node_t *node, int where);
/*
* 'main()' - Main entry for test program.
*/
int /* O - Exit status */
main(int argc, /* I - Number of command-line args */
char *argv[]) /* I - Command-line args */
{
int i; /* Looping var */
int len; /* Length of argument */
FILE *fp; /* File to read */
mxml_node_t *doc; /* XML documentation tree */
mxml_node_t *mxmldoc; /* mxmldoc node */
const char *cssfile, /* CSS stylesheet file */
*docset, /* Documentation set directory */
*docversion, /* Documentation set version */
*feedname, /* Feed name for documentation set */
*feedurl, /* Feed URL for documentation set */
*footerfile, /* Footer file */
*framefile, /* Framed HTML basename */
*headerfile, /* Header file */
*introfile, /* Introduction file */
*name, /* Name of manpage */
*path, /* Path to help file for tokens */
*section, /* Section/keywords of documentation */
*title, /* Title of documentation */
*xmlfile; /* XML file */
int mode, /* Output mode */
update; /* Updated XML file */
/*
* Check arguments...
*/
cssfile = NULL;
doc = NULL;
docset = NULL;
docversion = NULL;
feedname = NULL;
feedurl = NULL;
footerfile = NULL;
framefile = NULL;
headerfile = NULL;
introfile = NULL;
mode = OUTPUT_HTML;
mxmldoc = NULL;
name = NULL;
path = NULL;
section = NULL;
title = NULL;
update = 0;
xmlfile = NULL;
for (i = 1; i < argc; i ++)
if (!strcmp(argv[i], "--help"))
{
/*
* Show help...
*/
usage(NULL);
}
else if (!strcmp(argv[i], "--version"))
{
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
mxml-2.9.tar.gz (81个子文件)
mxml-2.9
test.xml 867B
testmxml.c 19KB
mxml-private.c 7KB
mxml-file.c 63KB
mxml-index.c 13KB
ANNOUNCEMENT 490B
mxml.pc.in 229B
mxml.h 12KB
COPYING 26KB
mxml.spec 3KB
mxml-string.c 9KB
mxml-node.c 17KB
install-sh 5KB
mxml-get.c 8KB
mxml.xml 57KB
doc
logo.xcf.gz 14KB
schema.html 7KB
9.gif 1KB
4.gif 1KB
footer.man 130B
intro.html 5KB
relnotes.html 15KB
docset.css 2KB
makedocs.sh 786B
F.gif 641B
license.html 27KB
basics.html 19KB
3.gif 1KB
6.gif 1KB
A.gif 1KB
2.gif 1KB
D.gif 1KB
B.gif 1KB
7.gif 1KB
5.gif 1KB
docset.header 232B
E.gif 672B
logo.gif 6KB
chapters.xcf.gz 6KB
0.gif 1KB
1.gif 1KB
reference.html 73KB
intro.man 5KB
mxmldoc.xsd 7KB
mxmldoc.html 6KB
docset.intro 5KB
install.html 4KB
8.gif 1KB
mxml.book 925B
mxmldoc.man 4KB
reference.heading 142B
advanced.html 18KB
title.html 930B
mxml.html 185KB
C.gif 1KB
configure 160KB
CHANGES 13KB
mxml-private.h 1KB
test
enum.cxx 497B
function.cxx 2KB
dotest.sh 866B
type.cxx 104B
class.cxx 1KB
functype.cxx 77B
struct.cxx 946B
mxmldoc.c 140KB
mxml-entity.c 10KB
config.h.in 2KB
mxml-attr.c 7KB
mxml.list.in 3KB
mxml-search.c 7KB
Makefile.in 10KB
mxml-set.c 7KB
README 6KB
configure.in 8KB
vcnet
mxmldoc.vcproj 7KB
mxml.sln 3KB
testmxml.vcproj 8KB
mxml1.def 1KB
config.h 3KB
mxml1.vcproj 9KB
共 81 条
- 1
资源评论
lzx1446
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功