Mercurial > mozilla > hg > DocumentIt
comparison document_it.py @ 6:5a4c1339b2f9
more stubbing
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 01 Aug 2011 22:05:30 -0700 |
parents | 3464eda1af80 |
children | 6bf82220a04c |
comparison
equal
deleted
inserted
replaced
5:3464eda1af80 | 6:5a4c1339b2f9 |
---|---|
39 return path | 39 return path |
40 | 40 |
41 def parse_manifest(filename, directory=None): | 41 def parse_manifest(filename, directory=None): |
42 """ | 42 """ |
43 reads a documentation manifest; returns a list of two-tuples: | 43 reads a documentation manifest; returns a list of two-tuples: |
44 [ | 44 [(filename, destination)] |
45 """ | 45 """ |
46 | 46 |
47 assert os.path.exists(filename) and os.path.isfile(filename) | 47 assert os.path.exists(filename) and os.path.isfile(filename), "%s not found" % filename |
48 | |
48 if directory is None: | 49 if directory is None: |
49 directory = os.path.dirname(os.path.abspath(filename)) | 50 directory = os.path.dirname(os.path.abspath(filename)) |
50 lines = [line.strip() for line in file(filename).readlines()] | 51 lines = [line.strip() for line in file(filename).readlines()] |
51 lines = [line for line in lines | 52 lines = [line for line in lines |
52 if line and not line.startswith('#')] | 53 if line and not line.startswith('#')] |
78 else: | 79 else: |
79 return '' | 80 return '' |
80 | 81 |
81 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter()) | 82 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter()) |
82 parser.add_option('-d', '--directory', dest='directory', | 83 parser.add_option('-d', '--directory', dest='directory', |
83 help='render the documentation to this directory') | 84 help='render the documentation from this directory') |
84 parser.add_option('--dest', dest='dest', | 85 parser.add_option('--dest', dest='dest', |
85 default=DEST, | 86 default=DEST, |
86 help='base URL of destination') | 87 help='base directory or URL of destination') |
87 parser.add_option('-u', '--user', dest='user', | 88 parser.add_option('-u', '--user', dest='user', |
88 help='user name') | 89 help='user name') |
89 parser.add_option('--list', dest='list', action='store_true', | 90 parser.add_option('--list', dest='list', action='store_true', default=False, |
90 help="list packages") | 91 help="list files") |
91 options, manifests = parser.parse_args(args) | 92 options, manifests = parser.parse_args(args) |
92 | 93 |
94 # print help if no manifests given | |
93 if not args: | 95 if not args: |
94 parser.print_help() | 96 parser.print_help() |
95 parser.exit() | 97 parser.exit() |
96 | 98 |
97 # run setup_development.py in this directory | 99 # read the manifests |
98 # to ensure documentation is up to date | 100 files = [] |
99 # TODO; as yet unneeded | 101 for manifest in manifests: |
102 for item in parse_manifest(manifest): | |
103 if item not in files: | |
104 files.append(item) | |
105 if options.list: | |
106 for item in files: | |
107 print '%s -> %s' % (item[0], item[1]) | |
108 | |
100 | 109 |
101 # render and upload READMEs | 110 # render and upload READMEs |
102 # TODO | 111 if options.directory: |
103 | 112 pass |
104 | 113 else: |
114 # TODO check credentials | |
115 raise NotImplementedError | |
105 | 116 |
106 if __name__ == '__main__': | 117 if __name__ == '__main__': |
107 main() | 118 main() |