diff --git a/doc/mxmldoc.man b/doc/mxmldoc.man index 7f5304c..dd6fe9e 100644 --- a/doc/mxmldoc.man +++ b/doc/mxmldoc.man @@ -70,7 +70,9 @@ mxmldoc \- mini-xml documentation generator ] .br .B mxmldoc -\-\-tokens [ +\-\-tokens +.I path +[ .I filename.xml ] [ .I source file(s) diff --git a/mxmldoc.c b/mxmldoc.c index 6d4d83b..f80d69b 100644 --- a/mxmldoc.c +++ b/mxmldoc.c @@ -208,7 +208,8 @@ 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); +static void write_tokens(FILE *out, mxml_node_t *doc, + const char *path); static const char *ws_cb(mxml_node_t *node, int where); @@ -235,6 +236,7 @@ main(int argc, /* I - Number of command-line args */ *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 */ @@ -259,6 +261,7 @@ main(int argc, /* I - Number of command-line args */ mode = OUTPUT_HTML; mxmldoc = NULL; name = NULL; + path = NULL; section = NULL; title = NULL; update = 0; @@ -429,6 +432,12 @@ main(int argc, /* I - Number of command-line args */ */ mode = OUTPUT_TOKENS; + + i ++; + if (i < argc) + path = argv[i]; + else + usage(NULL); } else if (argv[i][0] == '-') { @@ -587,7 +596,7 @@ main(int argc, /* I - Number of command-line args */ fputs("\n" "\n", stdout); - write_tokens(stdout, mxmldoc); + write_tokens(stdout, mxmldoc, path); fputs("\n", stdout); break; @@ -2723,6 +2732,7 @@ usage(const char *option) /* I - Unknown option */ puts(" --no-output Do no generate documentation file"); puts(" --section section Set section name"); puts(" --title title Set documentation title"); + puts(" --tokens path Generate Xcode docset Tokens.xml file"); exit(1); } @@ -3384,7 +3394,7 @@ write_html(const char *section, /* I - Section */ fputs("\n" "\n", out); - write_tokens(out, doc); + write_tokens(out, doc, "index.html"); fputs("\n", out); @@ -5332,7 +5342,8 @@ write_toc(FILE *out, /* I - Output file */ static void write_tokens(FILE *out, /* I - Output file */ - mxml_node_t *doc) /* I - Document */ + mxml_node_t *doc, /* I - Document */ + const char *path) /* I - Path to help file */ { mxml_node_t *function, /* Current function */ *scut, /* Struct/class/union/typedef */ @@ -5359,13 +5370,13 @@ write_tokens(FILE *out, /* I - Output file */ NULL, NULL, MXML_DESCEND_FIRST); fprintf(out, "\n" - "Documentation/index.html\n" + "Documentation/%s\n" "%s\n" "//apple_ref/cpp/cl/%s\n" - "", cename, cename); + "", path, cename, cename); write_description(out, description, "", 1); fputs("\n" - "", out); + "\n", out); if ((function = find_public(scut, scut, "function")) != NULL) { @@ -5376,10 +5387,10 @@ write_tokens(FILE *out, /* I - Output file */ NULL, NULL, MXML_DESCEND_FIRST); fprintf(out, "\n" - "Documentation/index.html\n" + "Documentation/%s\n" "%s.%s\n" - "//apple_ref/cpp/clm/%s/%s", cename, - name, cename, name); + "//apple_ref/cpp/clm/%s/%s", path, + cename, name, cename, name); arg = mxmlFindElement(function, function, "returnvalue", NULL, NULL, MXML_DESCEND_FIRST); @@ -5460,7 +5471,7 @@ write_tokens(FILE *out, /* I - Output file */ fputs(");", out); fputs("\n" - "", out); + "\n", out); function = find_public(function, doc, "function"); } @@ -5482,10 +5493,10 @@ write_tokens(FILE *out, /* I - Output file */ NULL, NULL, MXML_DESCEND_FIRST); fprintf(out, "\n" - "Documentation/index.html\n" + "Documentation/%s\n" "%s\n" "//apple_ref/c/func/%s\n" - "", name, name); + "", path, name, name); write_description(out, description, "", 1); fputs("\n" "", out); @@ -5529,7 +5540,7 @@ write_tokens(FILE *out, /* I - Output file */ fputs(");", out); fputs("\n" - "", out); + "\n", out); function = find_public(function, doc, "function"); } @@ -5548,13 +5559,13 @@ write_tokens(FILE *out, /* I - Output file */ NULL, NULL, MXML_DESCEND_FIRST); fprintf(out, "\n" - "Documentation/index.html\n" + "Documentation/%s\n" "%s\n" "//apple_ref/c/tdef/%s\n" - "", name, name); + "", path, name, name); write_description(out, description, "", 1); fputs("\n" - "", out); + "\n", out); scut = find_public(scut, doc, "typedef"); } @@ -5573,13 +5584,13 @@ write_tokens(FILE *out, /* I - Output file */ NULL, NULL, MXML_DESCEND_FIRST); fprintf(out, "\n" - "Documentation/index.html\n" + "Documentation/%s\n" "%s\n" "//apple_ref/c/tag/%s\n" - "", name, name); + "", path, name, name); write_description(out, description, "", 1); fputs("\n" - "", out); + "\n", out); scut = find_public(scut, doc, "struct"); } @@ -5598,13 +5609,13 @@ write_tokens(FILE *out, /* I - Output file */ NULL, NULL, MXML_DESCEND_FIRST); fprintf(out, "\n" - "Documentation/index.html\n" + "Documentation/%s\n" "%s\n" "//apple_ref/c/tag/%s\n" - "", name, name); + "", path, name, name); write_description(out, description, "", 1); fputs("\n" - "", out); + "\n", out); scut = find_public(scut, doc, "union"); } @@ -5623,13 +5634,13 @@ write_tokens(FILE *out, /* I - Output file */ NULL, NULL, MXML_DESCEND_FIRST); fprintf(out, "\n" - "Documentation/index.html\n" + "Documentation/%s\n" "%s\n" "//apple_ref/c/data/%s\n" - "", name, name); + "", path, name, name); write_description(out, description, "", 1); fputs("\n" - "", out); + "\n", out); arg = find_public(arg, doc, "variable"); } @@ -5648,13 +5659,13 @@ write_tokens(FILE *out, /* I - Output file */ NULL, NULL, MXML_DESCEND_FIRST); fprintf(out, "\n" - "Documentation/index.html\n" + "Documentation/%s\n" "%s\n" "//apple_ref/c/tag/%s\n" - "", cename, cename); + "", path, cename, cename); write_description(out, description, "", 1); fputs("\n" - "", out); + "\n", out); for (arg = mxmlFindElement(scut, scut, "constant", NULL, NULL, MXML_DESCEND_FIRST); @@ -5666,13 +5677,13 @@ write_tokens(FILE *out, /* I - Output file */ description = mxmlFindElement(arg, arg, "description", NULL, NULL, MXML_DESCEND_FIRST); fprintf(out, "\n" - "Documentation/index.html\n" + "Documentation/%s\n" "%s\n" "//apple_ref/c/econst/%s\n" - "", cename, name); + "", path, cename, name); write_description(out, description, "", 1); fputs("\n" - "", out); + "\n", out); } scut = find_public(scut, doc, "enumeration");