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

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 5 years, 11 months 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/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved.
3 # 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
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Script to regenerate API docs using doxygen.
7 """
8
9 import argparse
6 import collections 10 import collections
7 import json 11 import json
8 import optparse
9 import os 12 import os
10 import shutil 13 import shutil
11 import subprocess 14 import subprocess
12 import sys 15 import sys
13 import tempfile 16 import tempfile
14 import urllib2 17 import urllib2
15 18
16 19
17 if sys.version_info < (2, 7, 0): 20 if sys.version_info < (2, 7, 0):
18 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
220 223
221 224
222 def RunRstIndex(kind, channel, pepper_version, out_dirname, out_rst_filename): 225 def RunRstIndex(kind, channel, pepper_version, out_dirname, out_rst_filename):
223 assert kind in ('root', 'c', 'cpp') 226 assert kind in ('root', 'c', 'cpp')
224 script = os.path.join(SCRIPT_DIR, 'rst_index.py') 227 script = os.path.join(SCRIPT_DIR, 'rst_index.py')
225 cmd = [sys.executable, script, 228 cmd = [sys.executable, script,
226 '--' + kind, 229 '--' + kind,
227 '--channel', channel, 230 '--channel', channel,
228 '--version', pepper_version, 231 '--version', pepper_version,
229 out_dirname, 232 out_dirname,
230 '-o', out_rst_filename] 233 out_rst_filename]
231 Trace('Running rst_index:\n %s' % ' '.join(cmd)) 234 Trace('Running rst_index:\n %s' % ' '.join(cmd))
232 subprocess.check_call(cmd) 235 subprocess.check_call(cmd)
233 236
234 237
235 def GetRstName(kind, channel): 238 def GetRstName(kind, channel):
236 if channel == 'stable': 239 if channel == 'stable':
237 filename = '%s-api.rst' % kind 240 filename = '%s-api.rst' % kind
238 else: 241 else:
239 filename = '%s-api-%s.rst' % (kind, channel) 242 filename = '%s-api-%s.rst' % (kind, channel)
240 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
281 RunDoxygen(out_dirname_cpp, doxyfile_cpp) 284 RunDoxygen(out_dirname_cpp, doxyfile_cpp)
282 RunDoxyCleanup(out_dirname_cpp) 285 RunDoxyCleanup(out_dirname_cpp)
283 RunRstIndex('cpp', channel, pepper_version, out_dirname_cpp, rst_index_cpp) 286 RunRstIndex('cpp', channel, pepper_version, out_dirname_cpp, rst_index_cpp)
284 finally: 287 finally:
285 # Cleanup 288 # Cleanup
286 RemoveDir(svn_dirname) 289 RemoveDir(svn_dirname)
287 RemoveDir(doxyfile_dirname) 290 RemoveDir(doxyfile_dirname)
288 291
289 292
290 def main(argv): 293 def main(argv):
291 parser = optparse.OptionParser(usage='Usage: %prog [options] <out_directory>') 294 parser = argparse.ArgumentParser(description=__doc__)
292 parser.add_option('-v', '--verbose', 295 parser.add_argument('-v', '--verbose',
293 help='Verbose output', action='store_true') 296 help='Verbose output', action='store_true')
294 options, dirs = parser.parse_args(argv) 297 parser.add_argument('out_directory')
298 options = parser.parse_args(argv)
295 299
296 if options.verbose: 300 if options.verbose:
297 Trace.verbose = True 301 Trace.verbose = True
298 302
299 if len(dirs) != 1:
300 parser.error('Expected an output directory')
301
302 channel_info = GetChannelInfo() 303 channel_info = GetChannelInfo()
303 for channel, info in channel_info.iteritems(): 304 for channel, info in channel_info.iteritems():
304 GenerateDocs(dirs[0], channel, info.version, info.branch) 305 GenerateDocs(options.out_directory, channel, info.version, info.branch)
305 306
306 return 0 307 return 0
307 308
308 309
309 if __name__ == '__main__': 310 if __name__ == '__main__':
310 try: 311 try:
311 rtn = main(sys.argv[1:]) 312 rtn = main(sys.argv[1:])
312 except KeyboardInterrupt: 313 except KeyboardInterrupt:
313 sys.stderr.write('%s: interrupted\n' % os.path.basename(__file__)) 314 sys.stderr.write('%s: interrupted\n' % os.path.basename(__file__))
314 rtn = 1 315 rtn = 1
315 sys.exit(rtn) 316 sys.exit(rtn)
OLDNEW
« no previous file with comments | « native_client_sdk/src/doc/doxygen/doxy_cleanup.py ('k') | native_client_sdk/src/doc/doxygen/rst_index.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698