summaryrefslogtreecommitdiff
path: root/man
diff options
context:
space:
mode:
authorSimon Howard2006-12-26 18:01:25 +0000
committerSimon Howard2006-12-26 18:01:25 +0000
commitb826c4691da8620276b4f9574d90374ff85f9793 (patch)
treea773734b4107535abfc631d986b16b882e085e79 /man
parent502ff6a666729f7b854e9c406030af24bb16d55c (diff)
downloadchocolate-doom-b826c4691da8620276b4f9574d90374ff85f9793.tar.gz
chocolate-doom-b826c4691da8620276b4f9574d90374ff85f9793.tar.bz2
chocolate-doom-b826c4691da8620276b4f9574d90374ff85f9793.zip
Remove command line options from README; move to autogenerated CMDLINE
file. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 812
Diffstat (limited to 'man')
-rw-r--r--man/Makefile.am8
-rwxr-xr-xman/docgen111
2 files changed, 104 insertions, 15 deletions
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]