Mercurial > mozilla > hg > DocumentIt
changeset 5:3464eda1af80
better formatting for command line
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 01 Aug 2011 21:54:31 -0700 |
parents | 550f4b240e20 |
children | 5a4c1339b2f9 |
files | document_it.py setup.py |
diffstat | 2 files changed, 17 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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 <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