Bläddra i källkod

libgis/html-description: print second keyword as a link to the 'topic' page

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@57897 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 11 år sedan
förälder
incheckning
1f0a85441d
2 ändrade filer med 36 tillägg och 3 borttagningar
  1. 9 0
      lib/gis/parser.c
  2. 27 3
      lib/gis/parser_html.c

+ 9 - 0
lib/gis/parser.c

@@ -742,6 +742,15 @@ int G__uses_new_gisprompt(void)
     return 0;
 }
 
+/*!
+  \brief Print list of keywords (internal use only)
+
+  If <em>format</em> function is NULL than list of keywords is printed
+  comma-separated.
+
+  \param[out] fd file where to print
+  \param format pointer to print function
+*/
 void G__print_keywords(FILE *fd, void (*format)(FILE *, const char *))
 {
     int i;

+ 27 - 3
lib/gis/parser_html.c

@@ -19,8 +19,9 @@
 
 #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_html(FILE *, const char *);
+static void print_escaped_for_html_options(FILE *, const char *);
+static void print_escaped_for_html_keywords(FILE * , const char *);
 
 /*!
   \brief Print module usage description in HTML format.
@@ -66,7 +67,7 @@ void G__usage_html(void)
 
     fprintf(stdout, "<h2>%s</h2>\n", _("KEYWORDS"));
     if (st->module_info.keywords) {
-	G__print_keywords(stdout, NULL);
+	G__print_keywords(stdout, print_escaped_for_html_keywords);
 	fprintf(stdout, "\n");
     }
     fprintf(stdout, "<h2>%s</h2>\n", _("SYNOPSIS"));
@@ -312,4 +313,27 @@ void print_escaped_for_html_options(FILE * f, const char *str)
 	}
     }
 }
+
+void print_escaped_for_html_keywords(FILE * f, const char * str)
+{
+    /* HTML link only for second keyword */
+    if (st->n_keys > 1 &&
+        strcmp(st->module_info.keywords[1], str) == 0) {
+    
+        const char *s;
+        
+        fprintf(f, "<a href=\"topic_");
+        for (s = str; *s; s++) {
+            switch (*s) {
+                do_escape(' ', "_");
+            default:
+                fputc(*s, f);
+            }
+        }
+        fprintf(f, ".html\">%s</a>", str);
+    }
+    else {
+        fprintf(f, "%s", str);
+    }
+}
 #undef do_escape