[Freeciv-Dev] Re: (PR#9685) Make server create a wiki server manual
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] Re: (PR#9685) Make server create a wiki server manual |
From: |
"Per I. Mathisen" <per@xxxxxxxxxxx> |
Date: |
Sat, 14 Aug 2004 13:39:52 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9685 >
On Sat, 14 Aug 2004, Per I. Mathisen wrote:
> Here is the 'server options' part of the server manual, as it is output by
> the "/manual" server command:
>
> http://www.leftist.net/perrin/manual1.html
>
> Any suggestions for improvements? I think maybe itshould be split up into
> the categories for easier viewing. And/or perhaps an initial menu of
> options, like the wiki page list of contents.
Here are server commands:
http://www.leftist.net/perrin/manual2.html
Synopsis is slightly bugged due to presence of "<" and ">" signs in the
text.
Patch attached.
- Per
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.335
diff -u -r1.335 stdinhand.c
--- server/stdinhand.c 9 Aug 2004 15:45:49 -0000 1.335
+++ server/stdinhand.c 14 Aug 2004 20:38:23 -0000
@@ -1163,6 +1163,7 @@
CMD_LOAD,
CMD_READ_SCRIPT,
CMD_WRITE_SCRIPT,
+ CMD_WRITE_MANUAL,
/* undocumented */
CMD_RFCSTYLE,
@@ -1490,6 +1491,11 @@
N_("write <file-name>"),
N_("Write current settings as server commands to file."), NULL
},
+ {"manual", ALLOW_HACK,
+ /* TRANS: translate text between <> only */
+ N_("manual"),
+ N_("Write the server manual."), NULL
+ },
{"rfcstyle", ALLOW_HACK,
"rfcstyle",
N_("Switch server output between 'RFC-style' and normal style."), NULL
@@ -2264,6 +2270,114 @@
}
/**************************************************************************
+ Write a server manual in html format.
+**************************************************************************/
+static bool manual_command(struct connection *caller, bool check)
+{
+ FILE *doc1;
+ FILE *doc2;
+
+ if (check) {
+ return TRUE; /* Always */
+ }
+ if (!is_reg_file_for_access("manual1.html", TRUE)
+ || !is_reg_file_for_access("manual2.html", TRUE)
+ || !(doc1 = fopen("manual1.html", "w"))
+ || !(doc2 = fopen("manual2.html", "w"))) {
+ freelog(LOG_ERROR, _("Could not write manual files."));
+ return FALSE;
+ }
+ /* while all languages */ {
+ int i;
+
+ fprintf(doc1, "<html><body>\n\n");
+ fprintf(doc1, "<h1>Freeciv %s server options</h1>\n\n", VERSION_STRING);
+
+ for (i = 0; settings[i].name; i++) {
+ struct settings_s *op = &settings[i];
+ static struct astring abuf = ASTRING_INIT;
+ const char *help = _(op->extra_help);
+
+ astr_minsize(&abuf, strlen(help) + 10);
+ strcpy(abuf.str, help);
+ wordwrap_string(abuf.str, 76);
+
+ fprintf(doc1, "<h3>%s - %s</h3>\n\n", op->name, _(op->short_help));
+ if (strlen(op->extra_help) > 0) {
+ fprintf(doc1, "<pre>%s</pre>\n\n", abuf.str);
+ }
+ fprintf(doc1, "<p>");
+ fprintf(doc1, _("Level: %s.<br>"), sset_level_names[op->level]);
+ fprintf(doc1, _("Category: %s.<br>"), sset_category_names[op->category]);
+ if (op->to_client == SSET_SERVER_ONLY) {
+ fprintf(doc1, _("Can only be used in server console. "));
+ }
+ if (sset_is_changeable(i)) {
+ fprintf(doc1, _("Can be changed during a game. "));
+ } else {
+ fprintf(doc1, _("Can <b>not</b> be changed during a game. "));
+ }
+ fprintf(doc1, "</p>\n\n");
+ switch (op->type) {
+ case SSET_BOOL:
+ fprintf(doc1,
+ _("<p>Minimum: 0, Default: %d, Maximum: 1</p>\n\n"),
+ op->bool_default_value ? 1 : 0);
+ if (*(op->bool_value) != op->bool_default_value) {
+ fprintf(doc1, _("<p class=\"changed\">Value set to %d</p>\n\n"),
+ *(op->bool_value));
+ }
+ break;
+ case SSET_INT:
+ fprintf(doc1,
+ _("<p>Minimum: %d, Default: %d, Maximum: %d</p>\n\n"),
+ op->int_min_value, op->int_default_value, op->int_max_value);
+ if (*(op->int_value) != op->int_default_value) {
+ fprintf(doc1, _("<p class=\"changed\">Value set to %d</p>\n\n"),
+ *(op->int_value));
+ }
+ break;
+ case SSET_STRING:
+ fprintf(doc1,
+ _("<p>Default: \"%s\"</p>\n\n"), op->string_default_value);
+ if (strcmp(op->string_value, op->string_default_value) != 0) {
+ fprintf(doc1, _("<p class=\"changed\">Value set to %s</p>\n\n"),
+ op->string_value);
+ }
+ break;
+ }
+ }
+
+ fprintf(doc2, "<html><body>\n\n");
+ fprintf(doc2, "<h1>Freeciv %s server commands</h1>\n\n", VERSION_STRING);
+ for (i = 0; i < CMD_NUM; i++) {
+ const struct command *cmd = &commands[i];
+
+ fprintf(doc2, _("<h3>%s - %s</h3>"), cmd->name, _(cmd->short_help));
+ if (cmd->synopsis) {
+ fprintf(doc2, _("<table><tr><td><pre>Synopsis:</pre></td><td>"));
+ fprintf(doc2, "<pre>%s</pre></td></tr></table>", _(cmd->synopsis));
+ }
+ fprintf(doc2, _("<p>Level: %s</p>"), cmdlevel_name(cmd->level));
+ if (cmd->extra_help) {
+ static struct astring abuf = ASTRING_INIT;
+ const char *help = _(cmd->extra_help);
+
+ astr_minsize(&abuf, strlen(help)+1);
+ strcpy(abuf.str, help);
+ wordwrap_string(abuf.str, 76);
+ fprintf(doc2, _("<p>Description:</p>"));
+ fprintf(doc2, "<pre>%s</pre>", abuf.str);
+ }
+ }
+
+ fclose(doc1);
+ fclose(doc2);
+ return TRUE;
+ }
+}
+
+/**************************************************************************
...
(Should this take a 'caller' argument for output? --dwp)
**************************************************************************/
@@ -4479,6 +4593,8 @@
return save_command(caller,arg, check);
case CMD_LOAD:
return load_command(caller, arg, check);
+ case CMD_WRITE_MANUAL:
+ return manual_command(caller, check);
case CMD_METAINFO:
return metainfo_command(caller, arg, check);
case CMD_METACONN:
- [Freeciv-Dev] Re: (PR#9685) Make server create a wiki server manual, Per I. Mathisen, 2004/08/12
- [Freeciv-Dev] Re: (PR#9685) Make server create a wiki server manual, Christian Knoke, 2004/08/12
- [Freeciv-Dev] Re: (PR#9685) Make server create a wiki server manual, Per I. Mathisen, 2004/08/14
- [Freeciv-Dev] Re: (PR#9685) Make server create a wiki server manual,
Per I. Mathisen <=
- [Freeciv-Dev] Re: (PR#9685) Make server create a wiki server manual, Jason Short, 2004/08/16
- [Freeciv-Dev] Re: (PR#9685) Make server create a wiki server manual, Per I. Mathisen, 2004/08/19
- [Freeciv-Dev] Re: (PR#9685) Make server create a wiki server manual, Jason Short, 2004/08/19
- [Freeciv-Dev] Re: (PR#9685) Make server create a wiki server manual, Jason Short, 2004/08/19
- [Freeciv-Dev] (PR#9685) manual autogenerator, Per I. Mathisen, 2004/08/20
|
|