Commit 473f6a6c authored by Morten Welinder's avatar Morten Welinder

Fnuc doc: improve testing and fix issues found.

parent 604266a2
......@@ -402,7 +402,7 @@ gnumeric_imexp (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
/***************************************************************************/
static GnmFuncHelp const help_imargument[] = {
{ GNM_FUNC_HELP_NAME, F_("IMARGUMENT:the argument theta of the complex number @{z} ") },
{ GNM_FUNC_HELP_NAME, F_("IMARGUMENT:the argument theta of the complex number @{z}") },
{ GNM_FUNC_HELP_ARG, F_("z:a complex number") },
{ GNM_FUNC_HELP_DESCRIPTION, F_("The argument theta of a complex number is its angle in radians from the real axis.") },
{ GNM_FUNC_HELP_NOTE, F_("If @{z} is not a valid complex number, #VALUE! is returned.") },
......@@ -757,7 +757,7 @@ gnumeric_imarcsin (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
/***************************************************************************/
static GnmFuncHelp const help_imarccos[] = {
{ GNM_FUNC_HELP_NAME, F_("IMARCCOS:the complex arccosine of the complex number ") },
{ GNM_FUNC_HELP_NAME, F_("IMARCCOS:the complex arccosine of the complex number") },
{ GNM_FUNC_HELP_ARG, F_("z:a complex number") },
{ GNM_FUNC_HELP_DESCRIPTION, F_("IMARCCOS returns the complex arccosine of the complex number "
"@{z}. The branch cuts are on the real axis, less than -1 and greater than 1.") },
......@@ -783,7 +783,7 @@ gnumeric_imarccos (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
/***************************************************************************/
static GnmFuncHelp const help_imarctan[] = {
{ GNM_FUNC_HELP_NAME, F_("IMARCTAN:the complex arctangent of the complex number ") },
{ GNM_FUNC_HELP_NAME, F_("IMARCTAN:the complex arctangent of the complex number") },
{ GNM_FUNC_HELP_ARG, F_("z:a complex number") },
{ GNM_FUNC_HELP_DESCRIPTION, F_("IMARCTAN returns the complex arctangent of the complex number "
"@{z}. The branch cuts are on the imaginary axis, below -i and above i.") },
......
......@@ -1898,7 +1898,7 @@ static GnmFuncHelp const help_duration[] = {
GNM_DATE_BASIS_HELP
{ GNM_FUNC_HELP_EXAMPLES, "=DURATION(TODAY(),TODAY()+365,0.05,0.08,4)"},
{ GNM_FUNC_HELP_EXAMPLES, "=DURATION(TODAY(),TODAY()+366,0.05,0.08,4)"},
{ GNM_FUNC_HELP_SEEALSO, "MDURATION, G_DURATION"},
{ GNM_FUNC_HELP_SEEALSO, "MDURATION,G_DURATION"},
{ GNM_FUNC_HELP_END }
};
......
......@@ -491,7 +491,7 @@ static GnmFuncHelp const help_isprime[] = {
{ GNM_FUNC_HELP_ARG, F_("n:positive integer")},
{ GNM_FUNC_HELP_DESCRIPTION, F_("ISPRIME returns TRUE if @{n} is prime and FALSE otherwise.")},
{ GNM_FUNC_HELP_EXAMPLES, "=ISPRIME(57)" },
{ GNM_FUNC_HELP_SEEALSO, "NT_D, NT_SIGMA"},
{ GNM_FUNC_HELP_SEEALSO, "NT_D,NT_SIGMA"},
{ GNM_FUNC_HELP_EXTREF, F_("wolfram:PrimeNumber.html") },
{ GNM_FUNC_HELP_END }
};
......
......@@ -835,7 +835,7 @@ static GnmFuncHelp const help_average[] = {
{ GNM_FUNC_HELP_ARG, F_("number2:second value")},
{ GNM_FUNC_HELP_EXCEL, F_("This function is Excel compatible.") },
{ GNM_FUNC_HELP_EXAMPLES, "=AVERAGE(11.4,17.3,21.3,25.9,40.1)" },
{ GNM_FUNC_HELP_SEEALSO, ("SUM, COUNT")},
{ GNM_FUNC_HELP_SEEALSO, ("SUM,COUNT")},
{ GNM_FUNC_HELP_EXTREF, F_("wiki:en:Arithmetic_mean") },
{ GNM_FUNC_HELP_EXTREF, F_("wolfram:ArithmeticMean.html") },
{ GNM_FUNC_HELP_END }
......@@ -1260,7 +1260,7 @@ static GnmFuncHelp const help_betadist[] = {
{ GNM_FUNC_HELP_NOTE, F_("If @{a} >= @{b} this function returns a #NUM! error.")},
{ GNM_FUNC_HELP_EXCEL, F_("This function is Excel compatible.") },
{ GNM_FUNC_HELP_EXAMPLES, "=BETADIST(0.12,2,3)" },
{ GNM_FUNC_HELP_SEEALSO, "BETAINV, BETA.DIST"},
{ GNM_FUNC_HELP_SEEALSO, "BETAINV,BETA.DIST"},
{ GNM_FUNC_HELP_END }
};
......
......@@ -285,7 +285,7 @@ static GnmFuncHelp const help_lenb[] = {
{ GNM_FUNC_HELP_EXCEL, F_("This function is Excel compatible.") },
{ GNM_FUNC_HELP_EXAMPLES, "=LENB(\"Helsinki\")" },
{ GNM_FUNC_HELP_EXAMPLES, "=LENB(\"L\xc3\xa9vy\")" },
{ GNM_FUNC_HELP_SEEALSO, "CHAR, CODE, LEN"},
{ GNM_FUNC_HELP_SEEALSO, "CHAR,CODE,LEN"},
{ GNM_FUNC_HELP_END}
};
......
......@@ -136,7 +136,6 @@ static GnmFuncHelp const help_gnumeric_version[] = {
{ GNM_FUNC_HELP_NAME, N_("GNUMERIC_VERSION:the current version of Gnumeric")},
{ GNM_FUNC_HELP_DESCRIPTION, N_("GNUMERIC_VERSION returns the version of gnumeric as a string.")},
{ GNM_FUNC_HELP_EXAMPLES, "=GNUMERIC_VERSION()" },
{ GNM_FUNC_HELP_SEEALSO, ""},
{ GNM_FUNC_HELP_END }
};
......@@ -151,7 +150,6 @@ gnumeric_version (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
static GnmFuncHelp const help_table[] = {
{ GNM_FUNC_HELP_NAME, N_("TABLE:internal function for data tables")},
{ GNM_FUNC_HELP_DESCRIPTION, N_("This function should not be called directly.")},
{ GNM_FUNC_HELP_SEEALSO, ""},
{ GNM_FUNC_HELP_END }
};
......
......@@ -985,6 +985,8 @@ gnm_func_sanity_check1 (GnmFunc *fd)
memset (counts, 0, sizeof (counts));
for (h = help; n-- > 0; h++) {
unsigned len;
g_assert (h->type <= GNM_FUNC_HELP_ODF);
counts[h->type]++;
......@@ -995,6 +997,7 @@ gnm_func_sanity_check1 (GnmFunc *fd)
continue;
}
len = h->text ? strlen (h->text) : 0;
switch (h->type) {
case GNM_FUNC_HELP_NAME:
if (g_ascii_strncasecmp (fd->name, h->text, nlen) ||
......@@ -1002,11 +1005,12 @@ gnm_func_sanity_check1 (GnmFunc *fd)
g_printerr ("%s: Invalid NAME record\n",
fd->name);
res = 1;
} else if (h->text[nlen + 1] == ' ') {
} else if (h->text[nlen + 1] == ' ' ||
h->text[len - 1] == ' ') {
g_printerr ("%s: Unwanted space in NAME record\n",
fd->name);
res = 1;
} else if (h->text[strlen (h->text) - 1] == '.') {
} else if (h->text[len - 1] == '.') {
g_printerr ("%s: Unwanted period in NAME record\n",
fd->name);
res = 1;
......@@ -1090,6 +1094,36 @@ gnm_func_sanity_check1 (GnmFunc *fd)
}
}
break;
case GNM_FUNC_HELP_SEEALSO: {
const char *p = h->text;
if (len == 0 || strchr (p, ' ')) {
g_printerr ("%s: Invalid SEEALSO record\n",
fd->name);
res = 1;
break;
}
while (p) {
char *ref;
const char *e = strchr (p, ',');
if (!e) e = p + strlen (p);
ref = g_strndup (p, e - p);
if (!gnm_func_lookup (ref, NULL)) {
g_printerr ("%s: unknown SEEALSO record\reference %s",
fd->name, ref);
res = 1;
}
g_free (ref);
if (*e == 0)
break;
else
p = e + 1;
}
break;
}
default:
; /* Nothing */
}
......@@ -1134,6 +1168,12 @@ gnm_func_sanity_check1 (GnmFunc *fd)
res = 1;
}
if (counts[GNM_FUNC_HELP_SEEALSO] > 1) {
g_printerr ("%s: Help has %d SEEALSO notes.\n",
fd->name, counts[GNM_FUNC_HELP_SEEALSO]);
res = 1;
}
return res;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment