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

Unified Diff: native_client_sdk/src/doc/doxygen/rst_index.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « native_client_sdk/src/doc/doxygen/generate_docs.py ('k') | native_client_sdk/src/test_all.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/doc/doxygen/rst_index.py
diff --git a/native_client_sdk/src/doc/doxygen/rst_index.py b/native_client_sdk/src/doc/doxygen/rst_index.py
index 9706f97c4dbad8d5e59241ae6bde67f8a2c1d61b..35e4f020bd681555da30eafbee2b2424249ce2b8 100755
--- a/native_client_sdk/src/doc/doxygen/rst_index.py
+++ b/native_client_sdk/src/doc/doxygen/rst_index.py
@@ -3,9 +3,12 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+"""Script to generate rst index file doxygen generated html files.
+"""
+
+import argparse
import cStringIO
import fnmatch
-import optparse
import os
import re
import sys
@@ -227,24 +230,18 @@ def GenerateCppIndex(root_dir, channel, version, out_filename):
def main(argv):
- usage = 'Usage: %prog [options] <--root|--c|--cpp> directory'
- parser = optparse.OptionParser(usage=usage)
- parser.add_option('--channel', help='pepper channel (stable, beta, dev)')
- parser.add_option('--version', help='pepper version (e.g. 32, 33, 34, etc.)')
- parser.add_option('--root', help='Generate root API index',
- action='store_true', default=False)
- parser.add_option('--c', help='Generate C API index', action='store_true',
- default=False)
- parser.add_option('--cpp', help='Generate C++ API index', action='store_true',
- default=False)
- parser.add_option('-o', '--output', help='output file.')
- options, files = parser.parse_args(argv)
-
- if len(files) != 1:
- parser.error('Expected one directory')
-
- if not options.output:
- parser.error('Need output file')
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('--channel', help='pepper channel (stable, beta, dev)')
+ parser.add_argument('--version', help='pepper version (e.g. 32, 33, etc.)')
+ parser.add_argument('--root', help='Generate root API index',
+ action='store_true', default=False)
+ parser.add_argument('--c', help='Generate C API index', action='store_true',
+ default=False)
+ parser.add_argument('--cpp', help='Generate C++ API index',
+ action='store_true', default=False)
+ parser.add_argument('directory', help='input directory')
+ parser.add_argument('output_file', help='output file')
+ options = parser.parse_args(argv)
if options.channel not in VALID_CHANNELS:
parser.error('Expected channel to be one of %s' % ', '.join(VALID_CHANNELS))
@@ -252,14 +249,16 @@ def main(argv):
if sum((options.c, options.cpp, options.root)) != 1:
parser.error('Exactly one of --c/--cpp/--root flags is required.')
- root_dir = files[0]
if options.c:
- GenerateCIndex(root_dir, options.channel, options.version, options.output)
+ GenerateCIndex(options.directory, options.channel, options.version,
+ options.output_file)
elif options.cpp:
- GenerateCppIndex(root_dir, options.channel, options.version, options.output)
+ GenerateCppIndex(options.directory, options.channel, options.version,
+ options.output_file)
elif options.root:
- GenerateRootIndex(options.channel, options.version, options.output)
+ GenerateRootIndex(options.channel, options.version,
+ options.output_file)
else:
assert(False)
return 0
« no previous file with comments | « native_client_sdk/src/doc/doxygen/generate_docs.py ('k') | native_client_sdk/src/test_all.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698