foxygit / doom Log in
commit b826c4691da8620276b4f9574d90374ff85f9793
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Tue Dec 26 18:01:25 2006 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Tue Dec 26 18:01:25 2006 +0000

    Remove command line options from README; move to autogenerated CMDLINE
    file.

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 812
---
 Makefile.am     |   4 ++
 README          |  38 +------------------
 man/Makefile.am |   8 ++--
 man/docgen      | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++------
 4 files changed, 110 insertions(+), 51 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index f02f55d3..8e2a5e39 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -31,6 +31,7 @@ EXTRA_DIST=                             \
         $(CODEBLOCKS_FILES)             \
         $(DATA_FILES)                   \
         config.h                        \
+        CMDLINE                         \
         HACKING                         \
         TODO                            \
         BUGS
@@ -40,3 +41,6 @@ MAINTAINERCLEANFILES =  $(AUX_DIST_GEN)
 docdir=$(prefix)/share/doc/@PACKAGE@
 SUBDIRS=textscreen src man setup

+CMDLINE : src/
+	./man/docgen -p $? > $@
+
diff --git a/README b/README
index f7584a45..7c4a6b51 100644
--- a/README
+++ b/README
@@ -25,42 +25,8 @@ The configuration can be edited using the chocolate-setup tool.

 == Command-line options ==

-In addition to the normal Doom command-line options, a number of extra
-options are supported.
-
-  -1                   Sets screenmultiply to 1 (see above)
-
-  -2                   Sets screenmultiply to 2 (see above), doubling up
-                       the screen by 2x.
-
-  -extraconfig <file>  Specifies a configuration file to use for
-                       Chocolate Doom-specific settings (the default
-                       is 'chocolate-doom.cfg')
-
-  -fullscreen          Runs the game fullscreen.
-
-  -nofullscreen        Runs the game in a window,
-  -window
-
-  -gameversion <ver>   Emulates a specific release of Doom 1.9.  Valid
-                       values are "1.9", "ultimate" and "final".
-
-  -grabmouse           Grabs the mouse during play (see above)
-
-  -nograbmouse         Does not grab the mouse during play (see above)
-
-  -iwad <file>         Specifies an IWAD file to use.
-
-  -longtics            When recording demos, records in the the modified
-                       "Doom v1.91" format to avoid losing turning
-                       resolution.
-
-  -merge <file>        Loads a PWAD but simulates merging it into the main
-                       IWAD (see below)
-
-  -novert              Turns on novert (see above)
-
-  -nonovert            Turns off novert (see above)
+For a complete list of command-line options, see the CMDLINE
+file.

 == Playing TCs ==

diff --git a/man/Makefile.am b/man/Makefile.am
index c0bccd1a..5aacd9f6 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -1,10 +1,10 @@

-MANPAGE_GEN_FILES=header footer
+MANPAGE_GEN_FILES=header footer docgen

 man_MANS=chocolate-doom.6

-EXTRA_DIST = $(man_MANS) $(MANPAGE_GEN_FILES)
+EXTRA_DIST = $(man_MANS) $(MANPAGE_GEN_FILES)

-chocolate-doom.6: $(MANPAGE_GEN_FILES)
-	./docgen -m > $@
+chocolate-doom.6: ../src $(MANPAGE_GEN_FILES)
+	./docgen -m $? > $@

diff --git a/man/docgen b/man/docgen
index f9bf1a6e..05eab579 100755
--- a/man/docgen
+++ b/man/docgen
@@ -28,6 +28,38 @@ class Category:
     def add_param(self, param):
         self.params.append(param)

+    # Find the maximum width of a parameter in this category
+
+    def paramtext_width(self):
+        w = 0
+
+        for p in self.params:
+            pw = len(p.name) + 5
+
+            if p.args:
+                pw += len(p.args)
+
+            if pw > w:
+                w = pw
+
+        return w
+
+    # Plain text output
+
+    def plaintext_output(self):
+        result = "=== %s ===\n\n" % self.description
+
+        self.params.sort()
+
+        w = self.paramtext_width()
+
+        for p in self.params:
+            result += p.plaintext_output(w)
+
+        result = result.rstrip() + "\n"
+
+        return result
+
     def manpage_output(self):
         result = ".SH " + self.description.upper() + "\n"

@@ -130,6 +162,45 @@ class Parameter:

         return result

+    def plaintext_output(self, w):
+
+        # Build the first line, with the argument on
+
+        line = "  " + self.name
+        if self.args:
+            line += " " + self.args
+
+        # pad up to the plaintext width
+
+        line += " " * (w - len(line))
+
+        # Build the description text
+
+        description = self.text
+
+        if self.platform:
+            description += " (%s only)" % self.platform
+
+        # Build the complete text for the argument
+        # Split the description into words and add a word at a time
+
+        result = ""
+        for word in re.split('\s+', description):
+
+            # Break onto the next line?
+
+            if len(line) + len(word) + 1 > 75:
+                result += line + "\n"
+                line = " " * w
+
+            # Add another word
+
+            line += word + " "
+
+        result += line + "\n\n"
+
+        return result
+
 def process_file(file):
     f = open(file)

@@ -177,10 +248,10 @@ def process_file(file):
     finally:
         f.close()

-def process_files():
+def process_files(dir):
     # Process all C source files.

-    files = glob.glob("../src/*.c")
+    files = glob.glob(dir + "/*.c")

     for file in files:
         process_file(file)
@@ -195,9 +266,9 @@ def print_file_contents(file):
     finally:
         f.close()

-def manpage_output():
+def manpage_output(dir):

-    process_files()
+    process_files(dir)

     print_file_contents("header")

@@ -209,8 +280,8 @@ def manpage_output():

     print_file_contents("footer")

-def wiki_output():
-    process_files()
+def wiki_output(dir):
+    process_files(dir)

     print categories[None].wiki_output()

@@ -218,10 +289,28 @@ def wiki_output():
         if c != None:
             print categories[c].wiki_output()

-if len(sys.argv) > 1 and sys.argv[1] == "-m":
-    manpage_output()
-elif len(sys.argv) > 1 and sys.argv[1] == "-w":
-    wiki_output()
+def plaintext_output(dir):
+    process_files(dir)
+
+    print "== Command line parameters =="
+    print
+    print "This is a list of the command line parameters supported by "
+    print "Chocolate Doom.  A number of additional parameters are supported "
+    print "in addition to those present in Vanilla Doom. "
+    print
+
+    print categories[None].plaintext_output()
+
+    for c in categories:
+        if c != None:
+            print categories[c].plaintext_output()
+
+if len(sys.argv) > 2 and sys.argv[1] == "-m":
+    manpage_output(sys.argv[2])
+elif len(sys.argv) > 2 and sys.argv[1] == "-w":
+    wiki_output(sys.argv[2])
+elif len(sys.argv) > 2 and sys.argv[1] == "-p":
+    plaintext_output(sys.argv[2])
 else:
-    print "%s [ -m | -w ]" % sys.argv[0]
+    print "%s [ -m | -w | -p ] <directory>" % sys.argv[0]