Fix some comment parsing strangeness and tweak the presentation of functions

and constants to be more compact.
This commit is contained in:
Michael Sweet 2017-06-08 09:42:00 -04:00
parent 3b4fe17065
commit 888fd3f169
3 changed files with 623 additions and 845 deletions

View File

@ -1,4 +1,4 @@
.TH mxml 3 "Mini-XML API" "06/07/17" "Mini-XML API" .TH mxml 3 "Mini-XML API" "06/08/17" "Mini-XML API"
.SH NAME .SH NAME
mxml \- Mini-XML API mxml \- Mini-XML API
.SH INCLUDE FILE .SH INCLUDE FILE
@ -244,7 +244,7 @@ void mxmlAdd (
); );
.fi .fi
.SS mxmlDelete .SS mxmlDelete
Insert node after this child...
.PP .PP
.nf .nf
void mxmlDelete ( void mxmlDelete (

File diff suppressed because it is too large Load Diff

View File

@ -2093,6 +2093,8 @@ scan_file(const char *filename, /* I - Filename */
fputs(" #preprocessor...\n", stderr); fputs(" #preprocessor...\n", stderr);
#endif /* DEBUG */ #endif /* DEBUG */
state = STATE_PREPROCESSOR; state = STATE_PREPROCESSOR;
while (comment->child)
mxmlDelete(comment->child);
break; break;
case '\'' : /* Character constant */ case '\'' : /* Character constant */
@ -3726,7 +3728,7 @@ write_description(
int mode, /* I - Output mode */ int mode, /* I - Output mode */
mxml_node_t *description, /* I - Description node */ mxml_node_t *description, /* I - Description node */
const char *element, /* I - HTML element, if any */ const char *element, /* I - HTML element, if any */
int summary) /* I - Show summary */ int summary) /* I - Show summary (-1 for all) */
{ {
char text[10240], /* Text for description */ char text[10240], /* Text for description */
*start, /* Start of code/link */ *start, /* Start of code/link */
@ -3748,9 +3750,9 @@ write_description(
ptr = text; ptr = text;
} }
else if (!ptr || !ptr[2]) else if (summary >= 0 && (!ptr || !ptr[2]))
return; return;
else else if (summary >= 0)
ptr += 2; ptr += 2;
if (element && *element) if (element && *element)
@ -3888,7 +3890,12 @@ write_description(
} }
if (element && *element) if (element && *element)
fprintf(out, "</%s>\n", element); {
if (summary < 0)
fprintf(out, "</%s>", element);
else
fprintf(out, "</%s>\n", element);
}
else if (!element) else if (!element)
putc('\n', out); putc('\n', out);
} }
@ -4750,10 +4757,8 @@ write_function(FILE *out, /* I - Output file */
*node; /* Node in description */ *node; /* Node in description */
const char *name, /* Name of function/type */ const char *name, /* Name of function/type */
*defval; /* Default value */ *defval; /* Default value */
char prefix; /* Prefix character */ const char *prefix; /* Prefix string */
char *sep; /* Newline separator */ char *sep; /* Newline separator */
const char *br = mode == OUTPUT_EPUB ? "<br />" : "<br>";
/* Break sequence */
name = mxmlElementGetAttr(function, "name"); name = mxmlElementGetAttr(function, "name");
@ -4777,17 +4782,17 @@ write_function(FILE *out, /* I - Output file */
else else
fputs("void ", out); fputs("void ", out);
fprintf(out, "%s ", name); fputs(name, out);
for (arg = mxmlFindElement(function, function, "argument", NULL, NULL, for (arg = mxmlFindElement(function, function, "argument", NULL, NULL,
MXML_DESCEND_FIRST), prefix = '('; MXML_DESCEND_FIRST), prefix = "(";
arg; arg;
arg = mxmlFindElement(arg, function, "argument", NULL, NULL, arg = mxmlFindElement(arg, function, "argument", NULL, NULL,
MXML_NO_DESCEND), prefix = ',') MXML_NO_DESCEND), prefix = ", ")
{ {
type = mxmlFindElement(arg, arg, "type", NULL, NULL, type = mxmlFindElement(arg, arg, "type", NULL, NULL,
MXML_DESCEND_FIRST); MXML_DESCEND_FIRST);
fprintf(out, "%c%s\n&#160;&#160;&#160;&#160;", prefix, br); fputs(prefix, out);
if (type->child) if (type->child)
write_element(out, doc, type, mode); write_element(out, doc, type, mode);
@ -4796,14 +4801,14 @@ write_function(FILE *out, /* I - Output file */
fprintf(out, " %s", defval); fprintf(out, " %s", defval);
} }
if (prefix == '(') if (!strcmp(prefix, "("))
fputs("(void);</p>\n", out); fputs("(void);</p>\n", out);
else else
{ {
fprintf(out, fprintf(out,
"%s\n);</p>\n" ");</p>\n"
"<h%d class=\"parameters\">Parameters</h%d>\n" "<h%d class=\"parameters\">Parameters</h%d>\n"
"<dl>\n", br, level + 1, level + 1); "<table class=\"list\"><tbody>\n", level + 1, level + 1);
for (arg = mxmlFindElement(function, function, "argument", NULL, NULL, for (arg = mxmlFindElement(function, function, "argument", NULL, NULL,
MXML_DESCEND_FIRST); MXML_DESCEND_FIRST);
@ -4811,16 +4816,16 @@ write_function(FILE *out, /* I - Output file */
arg = mxmlFindElement(arg, function, "argument", NULL, NULL, arg = mxmlFindElement(arg, function, "argument", NULL, NULL,
MXML_NO_DESCEND)) MXML_NO_DESCEND))
{ {
fprintf(out, "<dt>%s</dt>\n", mxmlElementGetAttr(arg, "name")); fprintf(out, "<tr><th>%s</th>\n", mxmlElementGetAttr(arg, "name"));
adesc = mxmlFindElement(arg, arg, "description", NULL, NULL, adesc = mxmlFindElement(arg, arg, "description", NULL, NULL,
MXML_DESCEND_FIRST); MXML_DESCEND_FIRST);
write_description(out, mode, adesc, "dd", 1); write_description(out, mode, adesc, "td", -1);
write_description(out, mode, adesc, "dd", 0); fputs("</tr>\n", out);
} }
fputs("</dl>\n", out); fputs("</tbody></table>\n", out);
} }
arg = mxmlFindElement(function, function, "returnvalue", NULL, arg = mxmlFindElement(function, function, "returnvalue", NULL,
@ -5338,30 +5343,22 @@ write_html_body(
write_description(out, mode, description, "p", 1); write_description(out, mode, description, "p", 1);
fputs(" <h4 class=\"constants\">Constants</h4>\n" fputs(" <h4 class=\"constants\">Constants</h4>\n"
" <dl>\n", out); " <table class=\"list\"><tbody>\n", out);
#if 0
for (arg = mxmlFindElement(scut, scut, "constant", NULL, NULL,
MXML_DESCEND_FIRST);
arg;
arg = mxmlFindElement(arg, scut, "constant", NULL, NULL,
MXML_NO_DESCEND))
#else
for (arg = find_public(scut, scut, "constant", NULL, mode); for (arg = find_public(scut, scut, "constant", NULL, mode);
arg; arg;
arg = find_public(arg, scut, "constant", NULL, mode)) arg = find_public(arg, scut, "constant", NULL, mode))
#endif // 0
{ {
description = mxmlFindElement(arg, arg, "description", NULL, description = mxmlFindElement(arg, arg, "description", NULL,
NULL, MXML_DESCEND_FIRST); NULL, MXML_DESCEND_FIRST);
fprintf(out, " <dt>%s %s</dt>\n", fprintf(out, " <tr><th>%s %s</th>",
mxmlElementGetAttr(arg, "name"), get_comment_info(description)); mxmlElementGetAttr(arg, "name"), get_comment_info(description));
write_description(out, mode, description, "dd", 1); write_description(out, mode, description, "td", -1);
write_description(out, mode, description, "dd", 0); fputs("</tr>\n", out);
} }
fputs("</dl>\n", out); fputs("</tbody></table>\n", out);
scut = find_public(scut, doc, "enumeration", NULL, mode); scut = find_public(scut, doc, "enumeration", NULL, mode);
} }
@ -5565,8 +5562,10 @@ write_html_head(FILE *out, /* I - Output file */
" white-space: nowrap;\n" " white-space: nowrap;\n"
"}\n" "}\n"
"h3 span.info, h4 span.info {\n" "h3 span.info, h4 span.info {\n"
" border-top-left-radius: 10px;\n"
" border-top-right-radius: 10px;\n"
" float: right;\n" " float: right;\n"
" font-size: 100%;\n" " padding: 3px 6px;\n"
"}\n" "}\n"
"ul.code, ul.contents, ul.subcontents {\n" "ul.code, ul.contents, ul.subcontents {\n"
" list-style-type: none;\n" " list-style-type: none;\n"
@ -5582,15 +5581,25 @@ write_html_head(FILE *out, /* I - Output file */
"ul.contents li ul.code, ul.contents li ul.subcontents {\n" "ul.contents li ul.code, ul.contents li ul.subcontents {\n"
" padding-left: 2em;\n" " padding-left: 2em;\n"
"}\n" "}\n"
"div.body dl {\n" "table.list {\n"
" margin-top: 0;\n" " border-collapse: collapse;\n"
" width: 100%;\n"
"}\n" "}\n"
"div.body dt {\n" "table.list tr:nth-child(even) {\n"
" font-style: italic;\n" " background: rgba(127,127,127,0.1);]n"
" margin-top: 0;\n"
"}\n" "}\n"
"div.body dd {\n" "table.list th {\n"
" margin-bottom: 0.5em;\n" " border-right: 2px solid gray;\n"
" font-family: monospace;\n"
" padding: 5px 10px 5px 2px;\n"
" text-align: right;\n"
" vertical-align: top;\n"
"}\n"
"table.list td {\n"
" padding: 5px 2px 5px 10px;\n"
" text-align: left;\n"
" vertical-align: top;\n"
" width: 100%;\n"
"}\n" "}\n"
"h1.title {\n" "h1.title {\n"
"}\n" "}\n"
@ -6371,7 +6380,7 @@ write_scu(FILE *out, /* I - Output file */
fputs("};</p>\n" fputs("};</p>\n"
"<h4 class=\"members\">Members</h4>\n" "<h4 class=\"members\">Members</h4>\n"
"<dl>\n", out); "<table class=\"list\"><tbody>\n", out);
for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL,
MXML_DESCEND_FIRST); MXML_DESCEND_FIRST);
@ -6382,14 +6391,14 @@ write_scu(FILE *out, /* I - Output file */
description = mxmlFindElement(arg, arg, "description", NULL, description = mxmlFindElement(arg, arg, "description", NULL,
NULL, MXML_DESCEND_FIRST); NULL, MXML_DESCEND_FIRST);
fprintf(out, "<dt>%s %s</dt>\n", fprintf(out, "<tr><th>%s %s</th>\n",
mxmlElementGetAttr(arg, "name"), get_comment_info(description)); mxmlElementGetAttr(arg, "name"), get_comment_info(description));
write_description(out, mode, description, "dd", 1); write_description(out, mode, description, "td", -1);
write_description(out, mode, description, "dd", 0); fputs("</tr>\n", out);
} }
fputs("</dl>\n", out); fputs("</tbody></table>\n", out);
for (function = mxmlFindElement(scut, scut, "function", NULL, NULL, for (function = mxmlFindElement(scut, scut, "function", NULL, NULL,
MXML_DESCEND_FIRST); MXML_DESCEND_FIRST);