Mercurial > mozilla > hg > DocumentIt
comparison document_it.py @ 0:665b2ae2ecc6
stub project for DocumentIt
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 01 Aug 2011 12:00:51 -0700 |
parents | |
children | 53c7f9c7dfb6 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:665b2ae2ecc6 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 """ | |
4 update documentation for Mozmill | |
5 """ | |
6 | |
7 import os | |
8 import sys | |
9 import urllib2 | |
10 from optparse import OptionParser | |
11 | |
12 # necessary imports | |
13 try: | |
14 import markdown | |
15 except ImportError: | |
16 raise ImportError("markdown is not installed, run (e.g.):\neasy_install Markdown") | |
17 | |
18 DEST='http://developer.mozilla.org/' | |
19 DIR=os.path.dirname(os.path.abspath(__file__)) | |
20 README=['README.md', 'README.txt', 'README'] | |
21 | |
22 def find_readme(directory): | |
23 """find a README file in a directory""" | |
24 for name in README: | |
25 path = os.path.join(directory, name) | |
26 if os.path.exists(path): | |
27 return path | |
28 | |
29 def main(args=sys.argv[1:]): | |
30 | |
31 # parse command line options | |
32 usage = '%prog [options]' | |
33 parser = OptionParser(usage=usage, description=__doc__) | |
34 parser.add_option('-d', '--directory', dest='directory', | |
35 help='render the documentation to this directory') | |
36 parser.add_option('-p', '--package', dest='packages', | |
37 action='append', | |
38 help='package to operate on') | |
39 parser.add_option('--list', dest='list', action='store_true', | |
40 help="list packages") | |
41 options, args = parser.parse_args(args) | |
42 | |
43 # find packages | |
44 packages = options.__dict__.pop('packages') | |
45 if not packages: | |
46 packages = [i for i in os.listdir(DIR) | |
47 if os.path.isdir(os.path.join(DIR, i)) | |
48 and find_readme(os.path.join(DIR, i))] | |
49 if options.list: | |
50 for i in packages: | |
51 print i | |
52 | |
53 # run setup_development.py in this directory | |
54 # to ensure documentation is up to date | |
55 # TODO; as yet unneeded | |
56 | |
57 # render and upload READMEs | |
58 # TODO | |
59 | |
60 if __name__ == '__main__': | |
61 main() |