annotate document_it.py @ 1:53c7f9c7dfb6

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