Mercurial > mozilla > hg > DocumentIt
diff document_it.py @ 9:62bd66061329
add a helpful help message
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 01 Aug 2011 23:13:53 -0700 |
parents | f7fa35f972f4 |
children | 853214384bd0 |
line wrap: on
line diff
--- a/document_it.py Mon Aug 01 22:56:25 2011 -0700 +++ b/document_it.py Mon Aug 01 23:13:53 2011 -0700 @@ -1,7 +1,7 @@ #!/usr/bin/env python """ -update MDN documentation +update MDN documentation from markdown see: http://developer.mindtouch.com/en/ref/MindTouch_API/POST%3Apages%2F%2F%7Bpageid%7D%2F%2Fcontents @@ -12,11 +12,20 @@ jsbridge/README.txt https://developer.mozilla.org/en/JSbridge mozmill/README.txt https://developer.mozilla.org/en/Mozmill mozmill/docs/ https://developer.mozilla.org/en/Mozmill/ + +--dest sets the destination, e.g. + +--dest http://developer.mozilla.org/ +--dest https://developer-stage9.mozilla.org/jhammel +--dest path/to directory + +By default, a new temporary directory will be created """ import optparse import os import sys +import tempfile import urllib2 # necessary imports @@ -25,8 +34,6 @@ except ImportError: raise ImportError("markdown is not installed, run (e.g.):\neasy_install Markdown") -#DEST='http://developer.mozilla.org/' -DEST='https://developer-stage9.mozilla.org/jhammel' DIR=os.path.dirname(os.path.abspath(__file__)) # XXX currently unused def find_readme(directory): @@ -68,6 +75,9 @@ def main(args=sys.argv[1:]): + # default output directory + default_dir = tempfile.mktemp() + # parse command line options usage = '%prog [options] manifest <manifest> <...>' @@ -83,12 +93,15 @@ parser.add_option('-d', '--directory', dest='directory', help='render the documentation from this directory') parser.add_option('--dest', dest='dest', - default=DEST, - help='base directory or URL of destination') + default=default_dir, + help='base directory or URL of destination [DEFAULT: %default]') parser.add_option('-u', '--user', dest='user', help='user name') parser.add_option('--list', dest='list', action='store_true', default=False, help="list files") + parser.add_option('--validate', dest='validate', # TODO unused + action='store_true', default=False, + help="validate the rendering but don't output") options, manifests = parser.parse_args(args) # print help if no manifests given @@ -112,6 +125,9 @@ for item in files: print '%s -> %s/%s' % (item[0], baseurl.rstrip('/'), item[1].lstrip('/')) + if not files: + return # you're done + # render and upload READMEs if options.directory: @@ -122,10 +138,15 @@ os.makedirs(options.directory) # TODO render to directory - + for src, dest in files: + dest = os.path.join(options.dest, dest) + else: # TODO check credentials raise NotImplementedError + if options.dest = default_dir: + print "Files rendered to %s" % default_dir + if __name__ == '__main__': main()