# HG changeset patch # User Jeff Hammel # Date 1312260871 25200 # Node ID 3464eda1af8068c1606e896709be1b0366b4f423 # Parent 550f4b240e2002d85c0e66661ba52b01268277d9 better formatting for command line diff -r 550f4b240e20 -r 3464eda1af80 document_it.py --- a/document_it.py Mon Aug 01 18:31:27 2011 -0700 +++ b/document_it.py Mon Aug 01 21:54:31 2011 -0700 @@ -14,10 +14,10 @@ mozmill/docs/ https://developer.mozilla.org/en/Mozmill/ """ +import optparse import os import sys import urllib2 -from optparse import OptionParser # necessary imports try: @@ -26,13 +26,13 @@ raise ImportError("markdown is not installed, run (e.g.):\neasy_install Markdown") #DEST='http://developer.mozilla.org/' -DEST='https://developer-stage9.mozilla.org/' -DIR=os.path.dirname(os.path.abspath(__file__)) -README=['README.md', 'README.txt', 'README'] +DEST='https://developer-stage9.mozilla.org/jhammel' +DIR=os.path.dirname(os.path.abspath(__file__)) # XXX currently unused def find_readme(directory): """find a README file in a directory""" # XXX currently unused + README=['README.md', 'README.txt', 'README'] for name in README: path = os.path.join(directory, name) if os.path.exists(path): @@ -47,7 +47,7 @@ assert os.path.exists(filename) and os.path.isfile(filename) if directory is None: directory = os.path.dirname(os.path.abspath(filename)) - lines = [line.strip() for file(filename).readlines()] + lines = [line.strip() for line in file(filename).readlines()] lines = [line for line in lines if line and not line.startswith('#')] items = [] @@ -69,7 +69,16 @@ # parse command line options usage = '%prog [options] manifest <...>' - parser = OptionParser(usage=usage, description=__doc__) + + # description formatter + class PlainDescriptionFormatter(optparse.IndentedHelpFormatter): + def format_description(self, description): + if description: + return description + '\n' + else: + return '' + + parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter()) parser.add_option('-d', '--directory', dest='directory', help='render the documentation to this directory') parser.add_option('--dest', dest='dest', @@ -82,7 +91,7 @@ options, manifests = parser.parse_args(args) if not args: - parser.print_usage() + parser.print_help() parser.exit() # run setup_development.py in this directory diff -r 550f4b240e20 -r 3464eda1af80 setup.py --- a/setup.py Mon Aug 01 18:31:27 2011 -0700 +++ b/setup.py Mon Aug 01 21:54:31 2011 -0700 @@ -29,7 +29,7 @@ entry_points=""" # -*- Entry points: -*- [console_scripts] - document_it = document_it:main + document-it = document_it:main """, )