[gnumeric] Docs: Start introducing external references for function docs.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] Docs: Start introducing external references for function docs.
- Date: Tue, 16 Jun 2009 16:52:50 -0400 (EDT)
commit c926ed7acd8a922a4ee84b3fe7f081424bdd0e54
Author: Morten Welinder <terra gnome org>
Date: Tue Jun 16 16:52:29 2009 -0400
Docs: Start introducing external references for function docs.
ChangeLog | 7 +++
NEWS | 1 +
plugins/fn-math/ChangeLog | 5 ++
plugins/fn-math/functions.c | 47 ++++++++--------------
plugins/fn-stat/ChangeLog | 5 ++
plugins/fn-stat/functions.c | 4 ++
src/dialogs/dialog-function-select.c | 2 +
src/func.c | 70 +++++++++++++++++++++++++++++++++-
src/func.h | 3 +-
src/main-application.c | 9 ++++
10 files changed, 121 insertions(+), 32 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 75c046e..f6967b9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2009-06-16 Morten Welinder <terra gnome org>
+ * src/func.c (dump_externals): New function for creating what will
+ become http://projects.gnome.org/gnumeric/func-doc.shtml
+ (function_dump_defs): Call dump_externals for type 4.
+
+ * src/main-application.c (gnumeric_options): Introduce hidden
+ option for generating web page.
+
* src/gnm-pane.c (cb_control_point_event): Remove debug code.
* src/mstyle.c (gnm_style_update): Verify that empty styles have
diff --git a/NEWS b/NEWS
index 9deaefc..0b0c415 100644
--- a/NEWS
+++ b/NEWS
@@ -43,6 +43,7 @@ Morten:
* Implement new-from-template. [#303657]
* Add Gudermannian function GD.
* Fixed FIXED. No, really.
+ * Start introducing external references for function docs.
--------------------------------------------------------------------------
Gnumeric 1.9.8
diff --git a/plugins/fn-math/ChangeLog b/plugins/fn-math/ChangeLog
index 8483382..f281786 100644
--- a/plugins/fn-math/ChangeLog
+++ b/plugins/fn-math/ChangeLog
@@ -1,3 +1,8 @@
+2009-06-16 Morten Welinder <terra gnome org>
+
+ * functions.c: Start adding external references to a few
+ functions.
+
2009-06-09 Morten Welinder <terra gnome org>
* functions.c (gnumeric_acot, gnumeric_cot): New functions.
diff --git a/plugins/fn-math/functions.c b/plugins/fn-math/functions.c
index 4323fb6..932d02b 100644
--- a/plugins/fn-math/functions.c
+++ b/plugins/fn-math/functions.c
@@ -187,8 +187,9 @@ static GnmFuncHelp const help_gd[] = {
{ GNM_FUNC_HELP_NAME, F_("GD:Gudermannian function")},
{ GNM_FUNC_HELP_ARG, F_("x:value")},
{ GNM_FUNC_HELP_SEEALSO, "TAN,TANH"},
+ { GNM_FUNC_HELP_EXTREF, F_("wolfram:Gudermannian.html") },
+ { GNM_FUNC_HELP_EXTREF, F_("wiki:en:Gudermannian_function") },
{ GNM_FUNC_HELP_END }
-
};
static gnm_float
@@ -786,21 +787,14 @@ gnumeric_ceiling (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
/***************************************************************************/
static GnmFuncHelp const help_cos[] = {
- { GNM_FUNC_HELP_OLD,
- F_("@FUNCTION=COS\n"
- "@SYNTAX=COS(x)\n"
-
- "@DESCRIPTION="
- "COS function returns the cosine of @x, where @x is given "
- "in radians.\n\n"
- "* This function is Excel compatible.\n"
- "\n"
- "@EXAMPLES=\n"
- "COS(0.5) equals 0.877583.\n"
- "COS(1) equals 0.540302.\n"
- "\n"
- "@SEEALSO=COSH, SIN, SINH, TAN, TANH, RADIANS, DEGREES")
- },
+ { GNM_FUNC_HELP_NAME, F_("COS:Cosine function")},
+ { GNM_FUNC_HELP_ARG, F_("x:angle in radians")},
+ { GNM_FUNC_HELP_SEEALSO, "SIN,TAN,SINH,COSH,TANH,RADIANS,DEGREES"},
+ { GNM_FUNC_HELP_EXAMPLES, F_("COS(0.5) equals 0.877583") },
+ { GNM_FUNC_HELP_EXAMPLES, F_("COS(1) equals 0.540302") },
+ { GNM_FUNC_HELP_DESCRIPTION, F_("This function is Excel compatible.") },
+ { GNM_FUNC_HELP_EXTREF, F_("wolfram:Cosine.html") },
+ { GNM_FUNC_HELP_EXTREF, F_("wiki:en:Trigonometric_functions") },
{ GNM_FUNC_HELP_END }
};
@@ -1418,20 +1412,13 @@ gnumeric_radians (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
/***************************************************************************/
static GnmFuncHelp const help_sin[] = {
- { GNM_FUNC_HELP_OLD,
- F_("@FUNCTION=SIN\n"
- "@SYNTAX=SIN(x)\n"
-
- "@DESCRIPTION="
- "SIN function returns the sine of @x, where @x is given "
- "in radians.\n\n"
- "* This function is Excel compatible.\n"
- "\n"
- "@EXAMPLES=\n"
- "SIN(0.5) equals 0.479426.\n"
- "\n"
- "@SEEALSO=COS, COSH, SINH, TAN, TANH, RADIANS, DEGREES")
- },
+ { GNM_FUNC_HELP_NAME, F_("SIN:Sine function")},
+ { GNM_FUNC_HELP_ARG, F_("x:angle in radians")},
+ { GNM_FUNC_HELP_SEEALSO, "COS,TAN,SINH,COSH,TANH,RADIANS,DEGREES"},
+ { GNM_FUNC_HELP_EXAMPLES, F_("SIN((0.5) equals 0.479426") },
+ { GNM_FUNC_HELP_DESCRIPTION, F_("This function is Excel compatible.") },
+ { GNM_FUNC_HELP_EXTREF, F_("wolfram:Sine.html") },
+ { GNM_FUNC_HELP_EXTREF, F_("wiki:en:Trigonometric_functions") },
{ GNM_FUNC_HELP_END }
};
diff --git a/plugins/fn-stat/ChangeLog b/plugins/fn-stat/ChangeLog
index dce5804..f448580 100644
--- a/plugins/fn-stat/ChangeLog
+++ b/plugins/fn-stat/ChangeLog
@@ -1,3 +1,8 @@
+2009-06-16 Morten Welinder <terra gnome org>
+
+ * functions.c: Start adding external references to a few
+ functions.
+
2009-05-23 Morten Welinder <terra gnome org>
* Release 1.9.8
diff --git a/plugins/fn-stat/functions.c b/plugins/fn-stat/functions.c
index ae7c7a8..0bd7f0b 100644
--- a/plugins/fn-stat/functions.c
+++ b/plugins/fn-stat/functions.c
@@ -468,6 +468,8 @@ static GnmFuncHelp const help_mode[] = {
{ GNM_FUNC_HELP_EXAMPLES, F_("Let us assume that the cells A1, A2, ..., A5 contain numbers 11.4, 17.3, 11.4, 25.9, and 40.1.") },
{ GNM_FUNC_HELP_EXAMPLES, F_("Then MODE(A1:A5) equals 11.4.") },
{ GNM_FUNC_HELP_SEEALSO, "AVERAGE,MEDIAN"},
+ { GNM_FUNC_HELP_EXTREF, F_("wiki:en:Mode_(statistics)") },
+ { GNM_FUNC_HELP_EXTREF, F_("wolfram:Mode.html") },
{ GNM_FUNC_HELP_END }
};
@@ -1922,6 +1924,8 @@ static GnmFuncHelp const help_median[] = {
{ GNM_FUNC_HELP_EXAMPLES, F_("Let us assume that the cells A1, A2, ..., A5 contain numbers 11.4, 17.3, 21.3, 25.9, and 40.1.") },
{ GNM_FUNC_HELP_EXAMPLES, F_("Then MEDIAN(A1:A5) equals 21.3.") },
{ GNM_FUNC_HELP_SEEALSO, "AVERAGE,COUNT,COUNTA,DAVERAGE,MODE,SSMEDIAN,SUM"},
+ { GNM_FUNC_HELP_EXTREF, F_("wiki:en:Median") },
+ { GNM_FUNC_HELP_EXTREF, F_("wolfram:StatisticalMedian.html") },
{ GNM_FUNC_HELP_END }
};
diff --git a/src/dialogs/dialog-function-select.c b/src/dialogs/dialog-function-select.c
index 12dbd64..35ccd58 100644
--- a/src/dialogs/dialog-function-select.c
+++ b/src/dialogs/dialog-function-select.c
@@ -449,6 +449,8 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func)
}
case GNM_FUNC_HELP_END:
return;
+ case GNM_FUNC_HELP_EXTREF:
+ /* FIXME! */
default:
break;
}
diff --git a/src/func.c b/src/func.c
index 7fd6d82..8f4fee6 100644
--- a/src/func.c
+++ b/src/func.c
@@ -200,6 +200,64 @@ split_at_colon (char const *s, char **rest)
return dup;
}
+static void
+dump_externals (GPtrArray *defs, FILE *out)
+{
+ unsigned int ui;
+
+ fprintf (out, "<!--#set var=\"title\" value=\"Gnumeric Web Documentation\" -->");
+ fprintf (out, "<!--#set var=\"rootdir\" value=\".\" -->");
+ fprintf (out, "<!--#include virtual=\"header-begin.shtml\" -->");
+ fprintf (out, "<link rel=\"stylesheet\" href=\"style/index.css\" type=\"text/css\"/>");
+ fprintf (out, "<!--#include virtual=\"header-end.shtml\" -->");
+ fprintf (out, "<!--set var=\"wolfram\" value=\"none\" -->");
+ fprintf (out, "<!--set var=\"wiki\" value=\"none\" -->");
+ fprintf (out, "<!--\n\n-->");
+
+ for (ui = 0; ui < defs->len; ui++) {
+ GnmFunc const *fd = g_ptr_array_index (defs, ui);
+ gboolean any = FALSE;
+ int j;
+
+ for (j = 0; fd->help[j].type != GNM_FUNC_HELP_END; j++) {
+ const char *s = _(fd->help[j].text);
+
+ switch (fd->help[j].type) {
+ case GNM_FUNC_HELP_EXTREF:
+ if (!any) {
+ any = TRUE;
+ fprintf (out, "<!--#if expr=\"${QUERY_STRING_UNESCAPED} = %s\" -->", fd->name);
+ }
+
+ if (strncmp (s, "wolfram:", 8) == 0) {
+ fprintf (out, "<!--#set var=\"wolfram\" value=\"%s\" -->", s + 8);
+ }
+ if (strncmp (s, "wiki:", 5) == 0) {
+ char *lang, *page;
+ lang = split_at_colon (s + 5, &page);
+ fprintf (out, "<!--#set var=\"wiki_lang\" value=\"%s\" -->", lang);
+ fprintf (out, "<!--#set var=\"wiki\" value=\"%s\" -->", page);
+ g_free (lang);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (any)
+ fprintf (out, "<!--#endif\n\n-->");
+ }
+
+ fprintf (out, "<ul>");
+ fprintf (out, "<!--#if expr=\"${wolfram} != none\"-->");
+ fprintf (out, "<li><a href=\"http://mathworld.wolfram.com/<!--#echo var=\"wolfram\" -->\">Wolfram Mathworld entry</a>.</li><!--#endif-->");
+ fprintf (out, "<!--#if expr=\"${wiki} != none\"--><li><a href=\"http://<!--#echo var=\"wiki_lang\" -->.wikipedia.org/wiki/<!--#echo var=\"wiki\" -->\">Wikipedia entry</a>.</li><!--#endif-->");
+ fprintf (out, "<li><a href=\"http://www.google.com/#q=<!--#echo var=\"QUERY_STRING_UNESCAPED\" -->\">Google Search</a>.</li>");
+ fprintf (out, "</ul>");
+
+ fprintf (out, "<!--#include virtual=\"footer.shtml\" -->\n");
+}
/**
* function_dump_defs :
@@ -211,8 +269,9 @@ split_at_colon (char const *s, char **rest)
* Right now
* 0 :
* 1 :
- * 2 :
+ * 2 : generate_po
* 3 : dump function usage count
+ * 4 : external refs
**/
void
function_dump_defs (char const *filename, int dump_type)
@@ -251,6 +310,13 @@ function_dump_defs (char const *filename, int dump_type)
ordered->len, sizeof (gpointer),
func_def_cmp);
+ if (dump_type == 4) {
+ dump_externals (ordered, output_file);
+ g_ptr_array_free (ordered, TRUE);
+ fclose (output_file);
+ return;
+ }
+
if (dump_type == 0) {
int unique = 0;
for (i = 0; i < ordered->len; i++) {
@@ -366,6 +432,8 @@ function_dump_defs (char const *filename, int dump_type)
break;
}
+ case GNM_FUNC_HELP_EXTREF:
+ /* FIXME! */
case GNM_FUNC_HELP_EXAMPLES:
case GNM_FUNC_HELP_END:
case GNM_FUNC_HELP_NOTE:
diff --git a/src/func.h b/src/func.h
index c75a101..dab7eb8 100644
--- a/src/func.h
+++ b/src/func.h
@@ -141,7 +141,8 @@ typedef enum {
GNM_FUNC_HELP_DESCRIPTION, /* <LONG DESCRIPTION (reference args using @{arg})> (translated) */
GNM_FUNC_HELP_NOTE, /* <SPECIAL CASES (reference args using @{arg})> (translated) */
GNM_FUNC_HELP_EXAMPLES, /* <TEXT and EXAMPLES ?? get a hook to enter the sample ?? > (translated) */
- GNM_FUNC_HELP_SEEALSO /* name,name,name ... (not translated) */
+ GNM_FUNC_HELP_SEEALSO, /* name,name,name ... (not translated) */
+ GNM_FUNC_HELP_EXTREF /* wolfram:Sine.html wiki:en:Trigonometric_functions */
} GnmFuncHelpType;
typedef struct {
GnmFuncHelpType type;
diff --git a/src/main-application.c b/src/main-application.c
index 8776854..409466c 100644
--- a/src/main-application.c
+++ b/src/main-application.c
@@ -63,6 +63,7 @@ static gboolean gnumeric_no_splash = FALSE;
static gboolean gnumeric_no_warnings = FALSE;
static gchar *func_def_file = NULL;
static gchar *func_state_file = NULL;
+static gchar *ext_refs_file = NULL;
static gchar *geometry = NULL;
static gchar **startup_files;
@@ -95,6 +96,12 @@ static const GOptionEntry gnumeric_options [] = {
N_("FILE")
},
{
+ "ext-refs-file", 0,
+ G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME, &ext_refs_file,
+ N_("Dumps web page for function help"),
+ N_("FILE")
+ },
+ {
"split-func", 0,
G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &split_funcdocs,
N_("Generate new help and po files"),
@@ -359,6 +366,8 @@ main (int argc, char const **argv)
return gnm_dump_func_defs (func_def_file, 1);
if (split_funcdocs)
return gnm_dump_func_defs (NULL, 2);
+ if (ext_refs_file)
+ return gnm_dump_func_defs (ext_refs_file, 4);
/* Keep in sync with .desktop file */
g_set_application_name (_("Gnumeric Spreadsheet"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]