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