node */
@@ -276,7 +287,7 @@ scan_file(const char *filename, /* I - Filename */
bufptr = buffer;
comment = mxmlNewElement(MXML_NO_PARENT, "temp");
- structure = NULL;
+ parent = tree;
function = NULL;
variable = NULL;
returnvalue = NULL;
@@ -324,6 +335,9 @@ scan_file(const char *filename, /* I - Filename */
break;
case '{' :
+ if (function)
+ sort_node(parent, function);
+
braces ++;
function = NULL;
variable = NULL;
@@ -344,6 +358,9 @@ scan_file(const char *filename, /* I - Filename */
break;
case ';' :
+ if (function)
+ mxmlDelete(function);
+
function = NULL;
variable = NULL;
break;
@@ -533,21 +550,25 @@ scan_file(const char *filename, /* I - Filename */
function = mxmlNewElement(MXML_NO_PARENT, "function");
mxmlElementSetAttr(function, "name", buffer);
- sort_node(tree, function);
+ if (!type->last_child ||
+ strcmp(type->last_child->value.text.string, "void"))
+ {
+ returnvalue = mxmlNewElement(function, "returnvalue");
- description = mxmlNewElement(function, "description");
- update_comment(function, comment->child);
- mxmlAdd(description, MXML_ADD_AFTER, MXML_ADD_TO_PARENT,
- comment->child);
+ description = mxmlNewElement(returnvalue, "description");
+ update_comment(returnvalue, comment->last_child);
+ mxmlAdd(description, MXML_ADD_AFTER, MXML_ADD_TO_PARENT,
+ comment->last_child);
- returnvalue = mxmlNewElement(function, "returnvalue");
+ mxmlAdd(returnvalue, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, type);
+ }
+ else
+ mxmlDelete(type);
- description = mxmlNewElement(returnvalue, "description");
- update_comment(returnvalue, comment->child);
+ description = mxmlNewElement(function, "description");
+ update_comment(function, comment->last_child);
mxmlAdd(description, MXML_ADD_AFTER, MXML_ADD_TO_PARENT,
- comment->child);
-
- mxmlAdd(returnvalue, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, type);
+ comment->last_child);
type = NULL;
}
@@ -572,11 +593,21 @@ scan_file(const char *filename, /* I - Filename */
variable = mxmlNewElement(MXML_NO_PARENT, "variable");
mxmlElementSetAttr(variable, "name", buffer);
- sort_node(tree, variable);
+ sort_node(parent, variable);
mxmlAdd(variable, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, type);
type = NULL;
}
+ else if (ch == '{' && type->child &&
+ (!strcmp(type->child->value.text.string, "class") ||
+ !strcmp(type->child->value.text.string, "enum") ||
+ !strcmp(type->child->value.text.string, "struct") ||
+ !strcmp(type->child->value.text.string, "typedef")))
+ {
+ /* Handle structure/class/enum/typedef... */
+ mxmlDelete(type);
+ type = NULL;
+ }
else
mxmlNewText(type, type->child != NULL, buffer);
}
@@ -657,7 +688,7 @@ sort_node(mxml_node_t *tree, /* I - Tree to sort into */
* 'update_comment()' - Update a comment node.
*/
-static void /* Returns nothing */
+static void
update_comment(mxml_node_t *parent, /* I - Parent node */
mxml_node_t *comment) /* I - Comment node */
{
@@ -728,6 +759,80 @@ update_comment(mxml_node_t *parent, /* I - Parent node */
}
+/*
+ * 'write_documentation()' - Write HTML documentation.
+ */
+
+static void
+write_documentation(mxml_node_t *doc) /* I - XML documentation */
+{
+ mxml_node_t *node, /* Current node */
+ *function, /* Current function */
+ *arg, /* Current argument */
+ *description, /* Description of function/var */
+ *type; /* Type of returnvalue/var */
+ const char *name; /* Name of function/type */
+
+
+ puts("");
+ puts("");
+ puts("");
+ puts("\tMini-XML Home Page");
+ puts("\t");
+ puts("");
+ puts("");
+
+ puts("Functions
");
+ puts("");
+
+ for (function = mxmlFindElement(doc, doc, "function", NULL, NULL,
+ MXML_DESCEND_FIRST);
+ function;
+ function = mxmlFindElement(function, doc, "function", NULL, NULL,
+ MXML_NO_DESCEND))
+ {
+ name = mxmlElementGetAttr(function, "name");
+ printf("\t- %s()
\n", name, name);
+ }
+
+ puts("
");
+
+ for (function = mxmlFindElement(doc, doc, "function", NULL, NULL,
+ MXML_DESCEND_FIRST);
+ function;
+ function = mxmlFindElement(function, doc, "function", NULL, NULL,
+ MXML_NO_DESCEND))
+ {
+ name = mxmlElementGetAttr(function, "name");
+ printf("\n", name, name);
+
+ description = mxmlFindElement(function, function, "description", NULL,
+ NULL, MXML_DESCEND_FIRST);
+ fputs("", stdout);
+ for (node = mxmlWalkNext(description, description, MXML_DESCEND);
+ node;
+ node = mxmlWalkNext(node, description, MXML_DESCEND))
+ if (node->type == MXML_TEXT)
+ {
+ if (node->value.text.whitespace)
+ putchar(' ');
+
+ fputs(node->value.text.string, stdout);
+ }
+
+ puts("
");
+ }
+
+ puts("");
+ puts("");
+
+}
+
+
/*
* 'ws_cb()' - Whitespace callback for saving.
*/
@@ -741,24 +846,18 @@ ws_cb(mxml_node_t *node, /* I - Element node */
name = node->value.element.name;
- if (!strcmp(name, "namespace") || !strcmp(name, "enumeration") ||
- !strcmp(name, "typedef") || !strcmp(name, "function") ||
- !strcmp(name, "variable") || !strcmp(name, "struct") ||
- !strcmp(name, "class") || !strcmp(name, "constant") ||
- !strcmp(name, "argument") || !strcmp(name, "returnvalue"))
- {
- if (where <= MXML_WS_AFTER_OPEN)
- return ('\n');
- }
- else if (where == MXML_WS_AFTER_CLOSE)
+ if ((!strcmp(name, "namespace") || !strcmp(name, "enumeration") ||
+ !strcmp(name, "typedef") || !strcmp(name, "function") ||
+ !strcmp(name, "variable") || !strcmp(name, "struct") ||
+ !strcmp(name, "class") || !strcmp(name, "constant") ||
+ !strcmp(name, "argument") || !strcmp(name, "returnvalue")) &&
+ where == MXML_WS_AFTER_CLOSE)
return ('\n');
- else if (where == MXML_WS_BEFORE_OPEN && strcmp(name, "?xml"))
- return ('\t');
return (0);
}
/*
- * End of "$Id: mxmldoc.c,v 1.6 2003/06/05 03:06:20 mike Exp $".
+ * End of "$Id: mxmldoc.c,v 1.7 2003/06/05 12:11:53 mike Exp $".
*/