Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: native_client_sdk/src/doc/doxygen/generate_docs.py

Issue 720233003: [NaCl SDK] Convert python scripts from optparse to argparse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2
3 # Copyright (c) 2014 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 4 # found in the LICENSE file.
6 5
6 """Script to regenerate API docs using doxygen.
7 """
8
7 import collections 9 import collections
8 import json 10 import json
9 import optparse 11 import argparse
binji 2014/11/13 23:57:02 sort
Sam Clegg 2014/11/30 17:55:12 Done.
10 import os 12 import os
11 import shutil 13 import shutil
12 import subprocess 14 import subprocess
13 import sys 15 import sys
14 import tempfile 16 import tempfile
15 import urllib2 17 import urllib2
16 18
17 19
18 if sys.version_info < (2, 7, 0): 20 if sys.version_info < (2, 7, 0):
19 sys.stderr.write("python 2.7 or later is required run this script\n") 21 sys.stderr.write("python 2.7 or later is required run this script\n")
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 223
222 224
223 def RunRstIndex(kind, channel, pepper_version, out_dirname, out_rst_filename): 225 def RunRstIndex(kind, channel, pepper_version, out_dirname, out_rst_filename):
224 assert kind in ('root', 'c', 'cpp') 226 assert kind in ('root', 'c', 'cpp')
225 script = os.path.join(SCRIPT_DIR, 'rst_index.py') 227 script = os.path.join(SCRIPT_DIR, 'rst_index.py')
226 cmd = [sys.executable, script, 228 cmd = [sys.executable, script,
227 '--' + kind, 229 '--' + kind,
228 '--channel', channel, 230 '--channel', channel,
229 '--version', pepper_version, 231 '--version', pepper_version,
230 out_dirname, 232 out_dirname,
231 '-o', out_rst_filename] 233 out_rst_filename]
232 Trace('Running rst_index:\n %s' % ' '.join(cmd)) 234 Trace('Running rst_index:\n %s' % ' '.join(cmd))
233 subprocess.check_call(cmd) 235 subprocess.check_call(cmd)
234 236
235 237
236 def GetRstName(kind, channel): 238 def GetRstName(kind, channel):
237 if channel == 'stable': 239 if channel == 'stable':
238 filename = '%s-api.rst' % kind 240 filename = '%s-api.rst' % kind
239 else: 241 else:
240 filename = '%s-api-%s.rst' % (kind, channel) 242 filename = '%s-api-%s.rst' % (kind, channel)
241 return os.path.join(DOC_DIR, filename) 243 return os.path.join(DOC_DIR, filename)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 RunDoxygen(out_dirname_cpp, doxyfile_cpp) 284 RunDoxygen(out_dirname_cpp, doxyfile_cpp)
283 RunDoxyCleanup(out_dirname_cpp) 285 RunDoxyCleanup(out_dirname_cpp)
284 RunRstIndex('cpp', channel, pepper_version, out_dirname_cpp, rst_index_cpp) 286 RunRstIndex('cpp', channel, pepper_version, out_dirname_cpp, rst_index_cpp)
285 finally: 287 finally:
286 # Cleanup 288 # Cleanup
287 RemoveDir(svn_dirname) 289 RemoveDir(svn_dirname)
288 RemoveDir(doxyfile_dirname) 290 RemoveDir(doxyfile_dirname)
289 291
290 292
291 def main(argv): 293 def main(argv):
292 parser = optparse.OptionParser(usage='Usage: %prog [options] <out_directory>') 294 parser = argparse.ArgumentParser(description=__doc__)
293 parser.add_option('-v', '--verbose', 295 parser.add_argument('-v', '--verbose',
294 help='Verbose output', action='store_true') 296 help='Verbose output', action='store_true')
binji 2014/11/13 23:57:02 nit: align
Sam Clegg 2014/11/30 17:55:12 Done.
295 options, dirs = parser.parse_args(argv) 297 parser.add_argument('dir')
binji 2014/11/13 23:57:02 better name: out_directory?
Sam Clegg 2014/11/30 17:55:12 Done.
298 options = parser.parse_args(argv)
296 299
297 if options.verbose: 300 if options.verbose:
298 Trace.verbose = True 301 Trace.verbose = True
299 302
300 if len(dirs) != 1:
301 parser.error('Expected an output directory')
302
303 channel_info = GetChannelInfo() 303 channel_info = GetChannelInfo()
304 for channel, info in channel_info.iteritems(): 304 for channel, info in channel_info.iteritems():
305 GenerateDocs(dirs[0], channel, info.version, info.branch) 305 GenerateDocs(options.dir, channel, info.version, info.branch)
306 306
307 return 0 307 return 0
308 308
309 309
310 if __name__ == '__main__': 310 if __name__ == '__main__':
311 try: 311 try:
312 rtn = main(sys.argv[1:]) 312 rtn = main(sys.argv[1:])
313 except KeyboardInterrupt: 313 except KeyboardInterrupt:
314 sys.stderr.write('%s: interrupted\n' % os.path.basename(__file__)) 314 sys.stderr.write('%s: interrupted\n' % os.path.basename(__file__))
315 rtn = 1 315 rtn = 1
316 sys.exit(rtn) 316 sys.exit(rtn)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698