0
|
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
|
1
|
18 #DEST='http://developer.mozilla.org/'
|
|
19 DEST='https://developer-stage9.mozilla.org/'
|
0
|
20 DIR=os.path.dirname(os.path.abspath(__file__))
|
|
21 README=['README.md', 'README.txt', 'README']
|
|
22
|
|
23 def find_readme(directory):
|
|
24 """find a README file in a directory"""
|
|
25 for name in README:
|
|
26 path = os.path.join(directory, name)
|
|
27 if os.path.exists(path):
|
|
28 return path
|
|
29
|
|
30 def main(args=sys.argv[1:]):
|
|
31
|
|
32 # parse command line options
|
|
33 usage = '%prog [options]'
|
|
34 parser = OptionParser(usage=usage, description=__doc__)
|
|
35 parser.add_option('-d', '--directory', dest='directory',
|
|
36 help='render the documentation to this directory')
|
|
37 parser.add_option('-p', '--package', dest='packages',
|
|
38 action='append',
|
|
39 help='package to operate on')
|
|
40 parser.add_option('--list', dest='list', action='store_true',
|
|
41 help="list packages")
|
|
42 options, args = parser.parse_args(args)
|
|
43
|
|
44 # find packages
|
|
45 packages = options.__dict__.pop('packages')
|
|
46 if not packages:
|
|
47 packages = [i for i in os.listdir(DIR)
|
|
48 if os.path.isdir(os.path.join(DIR, i))
|
|
49 and find_readme(os.path.join(DIR, i))]
|
|
50 if options.list:
|
|
51 for i in packages:
|
|
52 print i
|
|
53
|
|
54 # run setup_development.py in this directory
|
|
55 # to ensure documentation is up to date
|
|
56 # TODO; as yet unneeded
|
|
57
|
|
58 # render and upload READMEs
|
|
59 # TODO
|
|
60
|
|
61 if __name__ == '__main__':
|
|
62 main()
|