shithub: choc

Download patch

ref: c1f553b92a7a4873b33026463866101e18be8e76
parent: e0b8a7e0a9e0ee8c5983b94b849a8a69a5592464
author: Jonathan Dowland <jon@dow.land>
date: Mon Nov 27 17:24:04 EST 2017

further manpage substitutions and fixes

Convert chocolate-setup.6 into a template file and generate outputs
based on @PROGRAM_PREFIX@.

Add @PACKAGE_SHORTNAME@ to the list of parameters handed to docgen
and make appropriate substitutions in the manpage templates.

--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -30,6 +30,7 @@
            @PROGRAM_PREFIX@strife.6       \
            strife.cfg.5             \
            @PROGRAM_PREFIX@strife.cfg.5   \
+           @PROGRAM_PREFIX@setup.6  \
            @PROGRAM_PREFIX@server.6
 
 SETUP_MAN_PAGES =                          \
@@ -38,8 +39,7 @@
            @PROGRAM_PREFIX@hexen-setup.6   \
            @PROGRAM_PREFIX@strife-setup.6
 
-man_MANS = chocolate-setup.6              \
-           $(GENERATED_MAN_PAGES)         \
+man_MANS = $(GENERATED_MAN_PAGES)         \
            $(SETUP_MAN_PAGES)
 
 doomdocs_DATA    = INSTALL.doom    CMDLINE.doom
@@ -51,10 +51,10 @@
              $(doomdocs_DATA) $(hereticdocs_DATA) \
              $(hexendocs_DATA) $(strifedocs_DATA)
 DOCGEN = $(srcdir)/docgen
-DOCGEN_COMMON_ARGS = -n "@PROGRAM_SPREFIX@" -s "@PACKAGE_NAME@"
+DOCGEN_COMMON_ARGS = -n "@PROGRAM_SPREFIX@" -s "@PACKAGE_NAME@" -z "@PACKAGE_SHORTNAME@"
 
-$(SETUP_MAN_PAGES): chocolate-setup.6
-	cp $(srcdir)/chocolate-setup.6 $@
+$(SETUP_MAN_PAGES): @PROGRAM_PREFIX@setup.6
+	cp $(srcdir)/@PROGRAM_PREFIX@setup.6 $@
 
 @PROGRAM_PREFIX@doom.6: $(top_srcdir)/src $(MANPAGE_GEN_FILES)
 	$(DOCGEN) $(DOCGEN_COMMON_ARGS) \
@@ -136,6 +136,11 @@
 @PROGRAM_PREFIX@server.6: $(top_srcdir)/src $(MANPAGE_GEN_FILES)
 	$(DOCGEN) $(DOCGEN_COMMON_ARGS) \
                   -g server -m $(srcdir)/server.template \
+                  $(top_srcdir)/src > $@
+
+@PROGRAM_PREFIX@setup.6: $(top_srcdir)/src $(MANPAGE_GEN_FILES)
+	$(DOCGEN) $(DOCGEN_COMMON_ARGS) \
+                  -g setup -m $(srcdir)/setup.template \
                   $(top_srcdir)/src > $@
 
 strife.cfg.5: $(top_srcdir)/src default.cfg.template
--- a/man/chocolate-setup.6
+++ /dev/null
@@ -1,42 +1,0 @@
-.TH @PROGRAM_SPREFIX@\-setup 6
-.SH NAME
-@PROGRAM_SPREFIX@\-setup \- configuration tool for @PROGRAM_SPREFIX@\-doom
-.SH SYNOPSIS
-.B @PROGRAM_SPREFIX@\-setup
-[OPTIONS]
-.SH DESCRIPTION
-.PP
-@PACKAGE_NAME@ is a modern Doom engine designed to behave
-as similar to the original Doom game as is possible.
-.PP
-.B @PROGRAM_SPREFIX@\-setup
-is a tool for configuring @PACKAGE_NAME@. It provides a menu\-based
-interface for the display, joystick, keyboard, mouse, sound and
-compatibility settings.
-.PP
-.B @PROGRAM_SPREFIX@\-setup
-can also be used to start and join network games.
-.PP
-.SH OPTIONS
-.TP
-\fB-config <file>\fR
-Load configuration from the specified file, instead of default.cfg. 
-.TP
-\fB-extraconfig <file>\fR
-Load extra configuration from the specified file, instead of @PROGRAM_SPREFIX@\-doom.cfg. 
-.SH SEE ALSO
-\fB@CHOCOLATE_SPREFIX@\-doom\fR(6),
-\fBdefault.cfg\fR(5),
-\fB@CHOCOLATE_SPREFIX@\-doom.cfg\fR(5)
-.SH AUTHOR
-Chocolate Doom is written and maintained by Simon Howard.
-.PP
-This manual was written by Jonathan Dowland.
-.SH COPYRIGHT
-Copyright \(co id Software Inc.
-Copyright \(co 2005-8 Simon Howard.
-.br
-This is free software.  You may redistribute copies of it under the terms of
-the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
-There is NO WARRANTY, to the extent permitted by law.
-
--- a/man/docgen
+++ b/man/docgen
@@ -430,7 +430,7 @@
 
         process_file(path)
 
-def print_template(template_file, program_prefix, package_name, content):
+def print_template(template_file, program_prefix, package_name, package_shortname, content):
     f = io.open(template_file, encoding='UTF-8')
 
     try:
@@ -440,16 +440,18 @@
                 filename = match.group(1)
                 filename = os.path.join(os.path.dirname(template_file),
                                         filename)
-                print_template(filename, program_prefix, package_name, content)
+                print_template(filename, program_prefix, package_name, package_shortname, content)
             else:
                 line = line.replace("@content", content)
                 line = line.replace("@PROGRAM_SPREFIX@", program_prefix)
-                line = line.replace("@PACKAGE_SHORTNAME@", package_name)
+                line = line.replace("@PACKAGE_NAME@", package_name)
+                if package_shortname:
+                    line = line.replace("@PACKAGE_SHORTNAME@", package_shortname)
                 stdout(line.rstrip().encode('UTF-8') + b'\n')
     finally:
         f.close()
 
-def manpage_output(targets, program_prefix, package_name, template_file):
+def manpage_output(targets, program_prefix, package_name, package_shortname, template_file):
 
     content = ""
 
@@ -458,7 +460,7 @@
 
     content = content.replace("-", "\\-")
 
-    print_template(template_file, program_prefix, package_name, content)
+    print_template(template_file, program_prefix, package_name, package_shortname, content)
 
 def wiki_output(targets, template):
     read_wikipages()
@@ -466,7 +468,7 @@
     for t in targets:
         stdout(t.wiki_output().encode('UTF-8') + b'\n')
 
-def plaintext_output(targets, program_prefix, package_name, template_file):
+def plaintext_output(targets, program_prefix, package_name, package_shortname, template_file):
 
     content = ""
 
@@ -473,9 +475,9 @@
     for t in targets:
         content += t.plaintext_output() + "\n"
 
-    print_template(template_file, program_prefix, package_name, content)
+    print_template(template_file, program_prefix, package_name, package_shortname, content)
 
-def completion_output(targets, program_prefix, package_name, template_file):
+def completion_output(targets, program_prefix, package_name, package_shortname, template_file):
 
     content = ""
 
@@ -482,14 +484,15 @@
     for t in targets:
         content += t.completion_output() + "\n"
 
-    print_template(template_file, program_prefix, package_name, content)
+    print_template(template_file, program_prefix, package_name, package_shortname, content)
 
 def usage():
-    print("Usage: %s [-V] [-c tag] [-g game] -n name ( -m | -w | -p ) <dir>..." \
+    print("Usage: %s [-V] [-c tag] [-g game] -n program_name -s package_name [ -z shortname ] ( -m | -w | -p ) <dir>..." \
             % sys.argv[0])
     print("   -c :  Provide documentation for the specified configuration file")
     print("         (matches the given tag name in the source file)")
     print("   -s :  Package name (for substitution)")
+    print("   -z :  Package short-name (for substitution)")
     print("   -n :  Program name (for substitution)")
     print("   -m :  Manpage output")
     print("   -w :  Wikitext output")
@@ -501,7 +504,7 @@
 
 # Parse command line
 
-opts, args = getopt.getopt(sys.argv[1:], "n:s:m:wp:b:c:g:V")
+opts, args = getopt.getopt(sys.argv[1:], "n:s:z:m:wp:b:c:g:V")
 
 output_function = None
 template = None
@@ -509,6 +512,7 @@
 match_game = None
 program_prefix = None
 package_name = None
+package_shortname = None
 
 for opt in opts:
     if opt[0] == "-n":
@@ -515,6 +519,8 @@
         program_prefix = opt[1]
     if opt[0] == "-s":
         package_name = opt[1]
+    if opt[0] == "-z":
+        package_shortname = opt[1]
     if opt[0] == "-m":
         output_function = manpage_output
         template = opt[1]
@@ -556,5 +562,5 @@
 
     # Generate the output
 
-    output_function(documentation_targets, program_prefix, package_name, template)
+    output_function(documentation_targets, program_prefix, package_name, package_shortname, template)
 
--- a/man/heretic.template
+++ b/man/heretic.template
@@ -6,7 +6,7 @@
 [\fIOPTIONS\fR]
 .SH DESCRIPTION
 .PP
-Chocolate Heretic is a port of Raven Software's 1994 game "Heretic" that
+@PACKAGE_SHORTNAME@ Heretic is a port of Raven Software's 1994 game "Heretic" that
 aims to behave as similar to the original DOS version of Heretic as
 possible.
 .br
@@ -14,16 +14,16 @@
 .SH IWAD SEARCH PATHS
 @include iwad_paths.man
 .SH ENVIRONMENT
-This section describes environment variables that control Chocolate Heretic's
+This section describes environment variables that control @PACKAGE_SHORTNAME@ Heretic's
 behavior.
 @include environ.man
 .SH FILES
 .TP
 \fB$HOME/.local/share/@PROGRAM_SPREFIX@\-doom/heretic.cfg\fR
-The main configuration file for Chocolate Heretic.  See \fBheretic.cfg\fR(5).
+The main configuration file for @PACKAGE_SHORTNAME@ Heretic.  See \fBheretic.cfg\fR(5).
 .TP
 \fB$HOME/.local/share/@PROGRAM_SPREFIX@\-doom/@PROGRAM_SPREFIX@\-heretic.cfg\fR
-Extra configuration values that are specific to Chocolate Heretic and not
+Extra configuration values that are specific to @PACKAGE_SHORTNAME@ Heretic and not
 present in Vanilla Heretic. See \fB@PROGRAM_SPREFIX@\-heretic.cfg\fR(5).
 .SH SEE ALSO
 \fB@PROGRAM_SPREFIX@\-doom\fR(6),
--- a/man/hexen.template
+++ b/man/hexen.template
@@ -6,7 +6,7 @@
 [\fIOPTIONS\fR]
 .SH DESCRIPTION
 .PP
-Chocolate Hexen is a port of Raven Software's 1995 game "Hexen" that
+@PACKAGE_SHORTNAME@ Hexen is a port of Raven Software's 1995 game "Hexen" that
 aims to behave as similar to the original DOS version of Hexen as
 possible.
 .br
@@ -14,16 +14,16 @@
 .SH IWAD SEARCH PATHS
 @include iwad_paths.man
 .SH ENVIRONMENT
-This section describes environment variables that control Chocolate Hexen's
+This section describes environment variables that control @PACKAGE_SHORTNAME@ Hexen's
 behavior.
 @include environ.man
 .SH FILES
 .TP
 \fB$HOME/.local/share/@PROGRAM_SPREFIX@\-doom/hexen.cfg\fR
-The main configuration file for Chocolate Hexen.  See \fBhexen.cfg\fR(5).
+The main configuration file for @PACKAGE_SHORTNAME@ Hexen.  See \fBhexen.cfg\fR(5).
 .TP
 \fB$HOME/.local/share/@PROGRAM_SPREFIX@\-doom/@PROGRAM_SPREFIX@\-hexen.cfg\fR
-Extra configuration values that are specific to Chocolate Hexen and not
+Extra configuration values that are specific to @PACKAGE_SHORTNAME@ Hexen and not
 present in Vanilla Hexen.  See \fB@PROGRAM_SPREFIX@\-hexen.cfg\fR(5).
 .SH SEE ALSO
 \fB@PROGRAM_SPREFIX@\-doom\fR(6),
--- /dev/null
+++ b/man/setup.template
@@ -1,0 +1,42 @@
+.TH @PROGRAM_SPREFIX@\-setup 6
+.SH NAME
+@PROGRAM_SPREFIX@\-setup \- configuration tool for @PROGRAM_SPREFIX@\-doom
+.SH SYNOPSIS
+.B @PROGRAM_SPREFIX@\-setup
+[OPTIONS]
+.SH DESCRIPTION
+.PP
+@PACKAGE_NAME@ is a modern Doom engine designed to behave
+as similar to the original Doom game as is possible.
+.PP
+.B @PROGRAM_SPREFIX@\-setup
+is a tool for configuring @PACKAGE_NAME@. It provides a menu\-based
+interface for the display, joystick, keyboard, mouse, sound and
+compatibility settings.
+.PP
+.B @PROGRAM_SPREFIX@\-setup
+can also be used to start and join network games.
+.PP
+.SH OPTIONS
+.TP
+\fB-config <file>\fR
+Load configuration from the specified file, instead of default.cfg. 
+.TP
+\fB-extraconfig <file>\fR
+Load extra configuration from the specified file, instead of @PROGRAM_SPREFIX@\-doom.cfg. 
+.SH SEE ALSO
+\fB@PROGRAM_SPREFIX@\-doom\fR(6),
+\fBdefault.cfg\fR(5),
+\fB@PROGRAM_SPREFIX@\-doom.cfg\fR(5)
+.SH AUTHOR
+Chocolate Doom is written and maintained by Simon Howard.
+.PP
+This manual was written by Jonathan Dowland.
+.SH COPYRIGHT
+Copyright \(co id Software Inc.
+Copyright \(co 2005-8 Simon Howard.
+.br
+This is free software.  You may redistribute copies of it under the terms of
+the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
+There is NO WARRANTY, to the extent permitted by law.
+
--- a/man/strife.template
+++ b/man/strife.template
@@ -6,7 +6,7 @@
 [\fIOPTIONS\fR]
 .SH DESCRIPTION
 .PP
-Chocolate Strife is an accurate and complete recreation of Rogue
+@PACKAGE_SHORTNAME@ Strife is an accurate and complete recreation of Rogue
 Entertainment's "Strife: Quest for the Sigil". It was created through
 more than two years of reverse engineering effort with the blessings
 of the original programmers of the game (see the section HISTORY below).
@@ -16,7 +16,7 @@
 .SH IWAD SEARCH PATHS
 @include iwad_paths.man
 .SH ENVIRONMENT
-This section describes environment variables that control Chocolate Strife's
+This section describes environment variables that control @PACKAGE_SHORTNAME@ Strife's
 behavior.
 @include environ.man
 
@@ -23,10 +23,10 @@
 .SH FILES
 .TP
 \fB$HOME/.local/share/@PROGRAM_SPREFIX@\-doom/strife.cfg\fR
-The main configuration file for Chocolate Strife.  See \fBstrife.cfg\fR(5).
+The main configuration file for @PACKAGE_SHORTNAME@ Strife.  See \fBstrife.cfg\fR(5).
 .TP
 \fB$HOME/.local/share/@PROGRAM_SPREFIX@\-doom/@PROGRAM_SPREFIX@\-strife.cfg\fR
-Extra configuration values that are specific to Chocolate Strife and not
+Extra configuration values that are specific to @PACKAGE_SHORTNAME@ Strife and not
 present in Vanilla Strife.  See \fB@PROGRAM_SPREFIX@\-strife.cfg\fR(5).
 .SH SEE ALSO
 \fB@PROGRAM_SPREFIX@\-doom\fR(6),
@@ -57,15 +57,15 @@
 legal entities, this is effectively legal permission.
 
 .SH BUGS
-Chocolate Strife is almost, but not entirely perfect, in recreating the
+@PACKAGE_SHORTNAME@ Strife is almost, but not entirely perfect, in recreating the
 behavior of Vanilla Strife.  Help us by reporting any discrepancies you
 might notice between this executable and the vanilla DOS program.
 
 However, do *not* report any glitch that you can replicate in the vanilla EXE
-as a bug. The point of Chocolate Strife, like Chocolate Doom before it, is to
+as a bug. The point of @PACKAGE_SHORTNAME Strife, like Chocolate Doom before it, is to
 be as bug-compatible with the original game as possible. Also be aware that
 some glitches are impossible to compatibly recreate, and wherever this is the
-case, Chocolate Strife has erred on the side of not crashing the program,
+case, @PACKAGE_SHORTNAME@ Strife has erred on the side of not crashing the program,
 for example by initializing pointers to NULL rather than using them without
 setting a value first.