|
@@ -1,7 +1,7 @@
|
|
/*!
|
|
/*!
|
|
\file lib/gis/parser_rest.c
|
|
\file lib/gis/parser_rest.c
|
|
|
|
|
|
- \brief GIS Library - Argument parsing functions (REST output)
|
|
|
|
|
|
+ \brief GIS Library - Argument parsing functions (reStructuredText output)
|
|
|
|
|
|
(C) 2012 by the GRASS Development Team
|
|
(C) 2012 by the GRASS Development Team
|
|
|
|
|
|
@@ -18,13 +18,13 @@
|
|
|
|
|
|
#include "parser_local_proto.h"
|
|
#include "parser_local_proto.h"
|
|
|
|
|
|
-/*!
|
|
|
|
-static void print_escaped_for_html(FILE * f, const char *str);
|
|
|
|
-static void print_escaped_for_html_options(FILE * f, const char *str);
|
|
|
|
-*/
|
|
|
|
|
|
+
|
|
|
|
+static void print_escaped_for_rest(FILE * f, const char *str);
|
|
|
|
+static void print_escaped_for_rest_options(FILE * f, const char *str);
|
|
|
|
+
|
|
|
|
|
|
/*!
|
|
/*!
|
|
- \brief Print module usage description in HTML format.
|
|
|
|
|
|
+ \brief Print module usage description in reStructuredText format.
|
|
*/
|
|
*/
|
|
void G__usage_rest(void)
|
|
void G__usage_rest(void)
|
|
{
|
|
{
|
|
@@ -36,7 +36,7 @@ void G__usage_rest(void)
|
|
|
|
|
|
new_prompt = G__uses_new_gisprompt();
|
|
new_prompt = G__uses_new_gisprompt();
|
|
|
|
|
|
- if (!st->pgm_name) /* v.dave && r.michael */
|
|
|
|
|
|
+ if (!st->pgm_name)
|
|
st->pgm_name = G_program_name();
|
|
st->pgm_name = G_program_name();
|
|
if (!st->pgm_name)
|
|
if (!st->pgm_name)
|
|
st->pgm_name = "??";
|
|
st->pgm_name = "??";
|
|
@@ -58,24 +58,24 @@ void G__usage_rest(void)
|
|
fprintf(stdout," :alt: GRASS logo\n\n");
|
|
fprintf(stdout," :alt: GRASS logo\n\n");
|
|
|
|
|
|
fprintf(stdout,"%s\n----\n", _("NAME"));
|
|
fprintf(stdout,"%s\n----\n", _("NAME"));
|
|
- fprintf(stdout, "**%s**", st->pgm_name); /*! TODO fix bold + emphase now only bold */
|
|
|
|
|
|
+ fprintf(stdout, "**%s**", st->pgm_name);
|
|
|
|
|
|
if (st->module_info.label || st->module_info.description)
|
|
if (st->module_info.label || st->module_info.description)
|
|
fprintf(stdout, " - ");
|
|
fprintf(stdout, " - ");
|
|
|
|
|
|
if (st->module_info.label)
|
|
if (st->module_info.label)
|
|
- fprintf(stdout, "%s\n", st->module_info.label);
|
|
|
|
|
|
+ fprintf(stdout, "%s\n\n", st->module_info.label);
|
|
|
|
|
|
if (st->module_info.description)
|
|
if (st->module_info.description)
|
|
fprintf(stdout, "%s\n", st->module_info.description);
|
|
fprintf(stdout, "%s\n", st->module_info.description);
|
|
|
|
|
|
|
|
|
|
- fprintf(stdout, "%s\n--------\n", _("KEYWORDS"));
|
|
|
|
|
|
+ fprintf(stdout, "\n%s\n----------------------\n", _("KEYWORDS"));
|
|
if (st->module_info.keywords) {
|
|
if (st->module_info.keywords) {
|
|
G__print_keywords(stdout, NULL);
|
|
G__print_keywords(stdout, NULL);
|
|
fprintf(stdout, "\n");
|
|
fprintf(stdout, "\n");
|
|
}
|
|
}
|
|
- fprintf(stdout, "%s\n--------\n", _("SYNOPSIS"));
|
|
|
|
|
|
+ fprintf(stdout, "\n%s\n----------------------\n", _("SYNOPSIS"));
|
|
fprintf(stdout, "**%s**\n\n", st->pgm_name);
|
|
fprintf(stdout, "**%s**\n\n", st->pgm_name);
|
|
fprintf(stdout, "**%s** help\n\n", st->pgm_name);
|
|
fprintf(stdout, "**%s** help\n\n", st->pgm_name);
|
|
|
|
|
|
@@ -119,9 +119,9 @@ void G__usage_rest(void)
|
|
}
|
|
}
|
|
if (!opt->required)
|
|
if (!opt->required)
|
|
fprintf(stdout, " [");
|
|
fprintf(stdout, " [");
|
|
- fprintf(stdout, "**%s**=*%s*", opt->key, type);
|
|
|
|
|
|
+ fprintf(stdout, "**%s** = *%s*", opt->key, type);
|
|
if (opt->multiple) {
|
|
if (opt->multiple) {
|
|
- fprintf(stdout, "[,*%s*,...]", type);
|
|
|
|
|
|
+ fprintf(stdout, " [, *%s* ,...]", type);
|
|
}
|
|
}
|
|
if (!opt->required)
|
|
if (!opt->required)
|
|
fprintf(stdout, "] ");
|
|
fprintf(stdout, "] ");
|
|
@@ -131,10 +131,10 @@ void G__usage_rest(void)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (new_prompt)
|
|
if (new_prompt)
|
|
- fprintf(stdout, " [--**overwrite**] ");
|
|
|
|
|
|
+ fprintf(stdout, " [-- **overwrite**] ");
|
|
|
|
|
|
- fprintf(stdout, " [--**verbose**] ");
|
|
|
|
- fprintf(stdout, " [--**quiet**] ");
|
|
|
|
|
|
+ fprintf(stdout, " [-- **verbose**] ");
|
|
|
|
+ fprintf(stdout, " [-- **quiet**] ");
|
|
|
|
|
|
fprintf(stdout, "\n");
|
|
fprintf(stdout, "\n");
|
|
|
|
|
|
@@ -159,15 +159,15 @@ void G__usage_rest(void)
|
|
fprintf(stdout, "\n");
|
|
fprintf(stdout, "\n");
|
|
}
|
|
}
|
|
if (new_prompt) {
|
|
if (new_prompt) {
|
|
- fprintf(stdout, "**--overwrite**\n");
|
|
|
|
|
|
+ fprintf(stdout, "-- **overwrite**\n");
|
|
fprintf(stdout, " %s\n",
|
|
fprintf(stdout, " %s\n",
|
|
_("Allow output files to overwrite existing files"));
|
|
_("Allow output files to overwrite existing files"));
|
|
}
|
|
}
|
|
|
|
|
|
- fprintf(stdout, "**--verbose**\n");
|
|
|
|
|
|
+ fprintf(stdout, "-- **verbose**\n");
|
|
fprintf(stdout, " %s\n", _("Verbose module output"));
|
|
fprintf(stdout, " %s\n", _("Verbose module output"));
|
|
|
|
|
|
- fprintf(stdout, "**--quiet**\n");
|
|
|
|
|
|
+ fprintf(stdout, "-- **quiet**\n");
|
|
fprintf(stdout, " %s\n", _("Quiet module output"));
|
|
fprintf(stdout, " %s\n", _("Quiet module output"));
|
|
|
|
|
|
fprintf(stdout, "\n");
|
|
fprintf(stdout, "\n");
|
|
@@ -197,34 +197,45 @@ void G__usage_rest(void)
|
|
type = "string";
|
|
type = "string";
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- fprintf(stdout, "**%s** = *%s", opt->key, type);
|
|
|
|
|
|
+ fprintf(stdout, "**%s** = *%s*", opt->key, type);
|
|
if (opt->multiple) {
|
|
if (opt->multiple) {
|
|
- fprintf(stdout, "[,*%s*,...]", type);
|
|
|
|
|
|
+ fprintf(stdout, " [, *%s* ,...]", type);
|
|
}
|
|
}
|
|
- fprintf(stdout, "*");
|
|
|
|
|
|
+ /* fprintf(stdout, "*"); */
|
|
if (opt->required) {
|
|
if (opt->required) {
|
|
- fprintf(stdout, " ;**[required]**");
|
|
|
|
|
|
+ fprintf(stdout, " **[required]**");
|
|
}
|
|
}
|
|
- fprintf(stdout, "\n");
|
|
|
|
|
|
+ fprintf(stdout, "\n\n");
|
|
if (opt->label) {
|
|
if (opt->label) {
|
|
- fprintf(stdout, " %s\n", opt->label);
|
|
|
|
|
|
+ fprintf(stdout, "\t");
|
|
|
|
+ print_escaped_for_rest(stdout, opt->label);
|
|
|
|
+ /* fprintf(stdout, " %s\n", opt->label); */
|
|
|
|
+ fprintf(stdout, "\n\n");
|
|
}
|
|
}
|
|
if (opt->description) {
|
|
if (opt->description) {
|
|
- fprintf(stdout, " %s\n", opt->description);
|
|
|
|
|
|
+ fprintf(stdout, "\t");
|
|
|
|
+ print_escaped_for_rest(stdout, opt->description);
|
|
|
|
+ /* fprintf(stdout, " %s\n", opt->description); */
|
|
|
|
+ fprintf(stdout, "\n\n");
|
|
}
|
|
}
|
|
|
|
|
|
if (opt->options) {
|
|
if (opt->options) {
|
|
- fprintf(stdout, " %s: *", _("Options"));
|
|
|
|
- /*! print_escaped_for_html_options(stdout, opt->options); */
|
|
|
|
- fprintf(stdout, "%s", opt->options);
|
|
|
|
- fprintf(stdout, "*\n");
|
|
|
|
|
|
+ fprintf(stdout, "\t%s: *", _("Options"));
|
|
|
|
+ print_escaped_for_rest_options(stdout, opt->options);
|
|
|
|
+ /* fprintf(stdout, "%s", opt->options);*/
|
|
|
|
+ fprintf(stdout, "*\n\n");
|
|
}
|
|
}
|
|
|
|
|
|
if (opt->def) {
|
|
if (opt->def) {
|
|
- fprintf(stdout, " %s: *", _("Default"));
|
|
|
|
- /*! print_escaped_for_html(stdout, opt->def); */
|
|
|
|
- fprintf(stdout,"%s", opt->def);
|
|
|
|
- fprintf(stdout, "*\n");
|
|
|
|
|
|
+ fprintf(stdout, "\t%s:", _("Default"));
|
|
|
|
+ /* TODO check if value is empty
|
|
|
|
+ if (!opt->def.empty()){ */
|
|
|
|
+ fprintf(stdout, " *");
|
|
|
|
+ print_escaped_for_rest(stdout, opt->def);
|
|
|
|
+ /* fprintf(stdout,"%s", opt->def); */
|
|
|
|
+ fprintf(stdout, "*\n\n");
|
|
|
|
+ /* } */
|
|
|
|
+ fprintf(stdout, "\n\n");
|
|
}
|
|
}
|
|
|
|
|
|
if (opt->descs) {
|
|
if (opt->descs) {
|
|
@@ -232,12 +243,13 @@ void G__usage_rest(void)
|
|
|
|
|
|
while (opt->opts[i]) {
|
|
while (opt->opts[i]) {
|
|
if (opt->descs[i]) {
|
|
if (opt->descs[i]) {
|
|
- fprintf(stdout, " **");
|
|
|
|
- /*! print_escaped_for_html(stdout, opt->opts[i]); */
|
|
|
|
- fprintf(stdout,"%s", opt->opts[i]);
|
|
|
|
- fprintf(stdout, "**: ");
|
|
|
|
- /*! print_escaped_for_html(stdout, opt->descs[i]); */
|
|
|
|
- fprintf(stdout, "%s\n", opt->descs[i]);
|
|
|
|
|
|
+ fprintf(stdout, "\t\t**");
|
|
|
|
+ print_escaped_for_rest(stdout, opt->opts[i]);
|
|
|
|
+ /*fprintf(stdout,"%s", opt->opts[i]); */
|
|
|
|
+ fprintf(stdout, "** : ");
|
|
|
|
+ print_escaped_for_rest(stdout, opt->descs[i]);
|
|
|
|
+ /* fprintf(stdout, "%s\n", opt->descs[i]); */
|
|
|
|
+ fprintf(stdout, "\n\n");
|
|
}
|
|
}
|
|
i++;
|
|
i++;
|
|
}
|
|
}
|
|
@@ -253,42 +265,33 @@ void G__usage_rest(void)
|
|
|
|
|
|
|
|
|
|
/*!
|
|
/*!
|
|
- * \brief Format text for HTML output
|
|
|
|
-
|
|
|
|
|
|
+ * \brief Format text for reStructuredText output
|
|
|
|
+ */
|
|
#define do_escape(c,escaped) case c: fputs(escaped,f);break
|
|
#define do_escape(c,escaped) case c: fputs(escaped,f);break
|
|
- void print_escaped_for_html(FILE * f, const char *str)
|
|
|
|
|
|
+ void print_escaped_for_rest(FILE * f, const char *str)
|
|
{
|
|
{
|
|
const char *s;
|
|
const char *s;
|
|
|
|
|
|
for (s = str; *s; s++) {
|
|
for (s = str; *s; s++) {
|
|
switch (*s) {
|
|
switch (*s) {
|
|
- do_escape('&', "&");
|
|
|
|
- do_escape('<', "<");
|
|
|
|
- do_escape('>', ">");
|
|
|
|
- do_escape('\n', "<br>");
|
|
|
|
- do_escape('\t', " ");
|
|
|
|
|
|
+ do_escape('\n', "\n\n");
|
|
default:
|
|
default:
|
|
fputc(*s, f);
|
|
fputc(*s, f);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- void print_escaped_for_html_options(FILE * f, const char *str)
|
|
|
|
|
|
+ void print_escaped_for_rest_options(FILE * f, const char *str)
|
|
{
|
|
{
|
|
const char *s;
|
|
const char *s;
|
|
|
|
|
|
for (s = str; *s; s++) {
|
|
for (s = str; *s; s++) {
|
|
switch (*s) {
|
|
switch (*s) {
|
|
- do_escape('&', "&");
|
|
|
|
- do_escape('<', "<");
|
|
|
|
- do_escape('>', ">");
|
|
|
|
- do_escape('\n', "<br>");
|
|
|
|
- do_escape('\t', " ");
|
|
|
|
- do_escape(',', ", ");
|
|
|
|
|
|
+ do_escape('\n', "\n\n");
|
|
default:
|
|
default:
|
|
fputc(*s, f);
|
|
fputc(*s, f);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-*/
|
|
|
|
|
|
+
|
|
#undef do_escape
|
|
#undef do_escape
|