From 21a82fa12400568b67b378048a822f73f6d32a81 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 13 Dec 2007 22:26:16 +0000 Subject: Add @vanilla tag for Vanilla doom command line options. Add missing documentation for -nosound, -nomusic, -nosfx. Fix up some bugs with the docgen wikitext output and allow control over output of Vanilla options. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 984 --- man/docgen | 68 +++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 14 deletions(-) (limited to 'man/docgen') diff --git a/man/docgen b/man/docgen index 05eab579..fe68299d 100755 --- a/man/docgen +++ b/man/docgen @@ -6,7 +6,7 @@ # //! # // @arg # // @category Category -# // @platform # // # // Long description of the parameter # // @@ -19,6 +19,7 @@ import sys import re import glob +import getopt class Category: def __init__(self, description): @@ -54,7 +55,8 @@ class Category: w = self.paramtext_width() for p in self.params: - result += p.plaintext_output(w) + if p.should_show(): + result += p.plaintext_output(w) result = result.rstrip() + "\n" @@ -66,8 +68,9 @@ class Category: self.params.sort() for p in self.params: - result += ".TP\n" - result += p.manpage_output() + if p.should_show(): + result += ".TP\n" + result += p.manpage_output() return result @@ -77,7 +80,14 @@ class Category: self.params.sort() for p in self.params: - result += "; " + p.wiki_output() + "\n" + if p.should_show(): + result += "; " + p.wiki_output() + "\n" + + # Escape special HTML characters + + result = result.replace("&", "&") + result = result.replace("<", "<") + result = result.replace(">", ">") return result @@ -90,6 +100,10 @@ categories = { "compat": Category("Compatibility"), } +# Show options that are in Vanilla Doom? Or only new options? + +show_vanilla_options = True + class Parameter: def __cmp__(self, other): if self.name < other.name: @@ -103,12 +117,16 @@ class Parameter: self.args = None self.platform = None self.category = None + self.vanilla_option = False + + def should_show(self): + return not self.vanilla_option or show_vanilla_options def add_text(self, text): if len(text) <= 0: pass elif text[0] == "@": - match = re.match('@(\S+)\s+(.*)', text) + match = re.match('@(\S+)\s*(.*)', text) if not match: raise "Malformed option line: %s" % text @@ -122,6 +140,8 @@ class Parameter: self.platform = data elif option_type == "category": self.category = data + elif option_type == "vanilla": + self.vanilla_option = True else: raise "Unknown option type '%s'" % option_type @@ -158,7 +178,7 @@ class Parameter: result += self.text if self.platform: - result += "'''(%s only)'''" + result += "'''(%s only)'''" % self.platform return result @@ -305,12 +325,32 @@ def plaintext_output(dir): 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]) +def usage(): + print "Usage: %s [-V] ( -m | -w | -p ) " % sys.argv[0] + print " -m : Manpage output" + print " -w : Wikitext output" + print " -p : Plaintext output" + print " -V : Don't show Vanilla Doom options" + sys.exit(0) + +# Parse command line + +opts, args = getopt.getopt(sys.argv[1:], "mwpV") + +output_function = None + +for opt in opts: + if opt[0] == "-m": + output_function = manpage_output + elif opt[0] == "-w": + output_function = wiki_output + elif opt[0] == "-p": + output_function = plaintext_output + elif opt[0] == "-V": + show_vanilla_options = False + +if output_function == None or len(args) != 1: + usage() else: - print "%s [ -m | -w | -p ] " % sys.argv[0] + output_function(args[0]) -- cgit v1.2.3